# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152378 | Leonardo_Paes | Uzastopni (COCI17_uzastopni) | C++11 | 28 ms | 380 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;
long long sum(long long k){
return k*(k+1LL)>>1LL;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
long long n;
cin >> n;
for(int i=2; i<=min(n, 200000LL); i++){
long long ini=1, meio, fim=n, ans=-1LL;
while(ini<=fim){
meio = (ini+fim)>>1LL;
if((meio-i>=0LL) and (sum(meio)-sum(meio-i))>=n){
fim=meio-1LL;
ans=meio;
}
else{
ini=meio+1LL;
}
}
if((ans-i>=0LL) and (sum(ans)-sum(ans-i))==n){
cout << ans-i+1LL << " " << ans << "\n";
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |