#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
9 ms |
376 KB |
Output is correct |
5 |
Correct |
17 ms |
376 KB |
Output is correct |
6 |
Correct |
20 ms |
376 KB |
Output is correct |
7 |
Correct |
22 ms |
376 KB |
Output is correct |
8 |
Correct |
24 ms |
376 KB |
Output is correct |
9 |
Correct |
27 ms |
380 KB |
Output is correct |
10 |
Correct |
28 ms |
380 KB |
Output is correct |