結果
| 問題 | No.648 お や す み |
| コンテスト | |
| ユーザー |
basscl_sugi
|
| 提出日時 | 2018-05-21 20:16:42 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 401 bytes |
| 記録 | |
| コンパイル時間 | 926 ms |
| コンパイル使用メモリ | 182,492 KB |
| 実行使用メモリ | 15,948 KB |
| 最終ジャッジ日時 | 2026-03-17 13:11:59 |
| 合計ジャッジ時間 | 138,163 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 39 TLE * 45 |
ソースコード
#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;
}
basscl_sugi