# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
36286 | Kerim | Odd-even (IZhO11_oddeven) | C++14 | 0 ms | 2028 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"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
//~ freopen("file.in", "r", stdin);
ll n;
scanf("%lld",&n);
if(n==1){
puts("1");
return 0;
}
int BLOK=sqrt(n);
for(int i=BLOK;i>=0;i--)
if(i*1LL*(i+1)/2LL+(i+1)<n){
ll ans=i*1LL*(i+1)+(i+1);
n-=i*1LL*(i+1)/2LL+(i+1);
if(n==1){
printf("%lld\n",ans+1);
return 0;
}n--;ans++;
printf("%lld\n",ans+n*2LL);
break;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |