結果
問題 |
No.648 お や す み
|
ユーザー |
![]() |
提出日時 | 2018-05-21 20:16:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 401 bytes |
コンパイル時間 | 1,481 ms |
コンパイル使用メモリ | 165,740 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-28 15:34:11 |
合計ジャッジ時間 | 5,355 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 TLE * 1 -- * 52 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long f(int x){ return (1+x)*x/2; } int main(void){ long long x; cin>>x; int i=1; while(f(i)<x) i*=2; int l=i/2, r=i; while(l<=r){ if(f((l+r)/2)==x){ cout<<"YES\n"<<(l+r)/2<<endl; return 0; } if(f((l+r)/2)>x) r=(l+r)/2-1; else l=(l+r)/2+1; } cout<<"NO"<<endl; }