# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
152378 | Leonardo_Paes | Uzastopni (COCI17_uzastopni) | C++11 | 28 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |