# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
636900 | HossamHero7 | Subway (info1cup19_subway) | C++14 | 9 ms | 808 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
ll k;
cin>>k;
ll ans = 0;
int l=1;
int r=1e5;
while(l<=r){
ll md = l + r >> 1;
if(md*(md-1)/2 <= k){
ans = md;
l = md+1;
}
else r = md-1;
}
ll x = k-ans*(ans-1)/2;
x --;
cout<<ans+(x>=0)<<endl;
cout<<0<<" "<<-1<<endl;
for(int i=0;i<ans-1;i++){
cout<<i+1<<" "<<i<<endl;
}
if(x>=0)cout<<ans<<' '<<x<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |