Submission #152378

#TimeUsernameProblemLanguageResultExecution timeMemory
152378Leonardo_PaesUzastopni (COCI17_uzastopni)C++11
80 / 80
28 ms380 KiB
#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 timeMemoryGrader output
Fetching results...