結果
問題 |
No.648 お や す み
|
ユーザー |
![]() |
提出日時 | 2018-02-14 02:12:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 1,628 ms |
コンパイル使用メモリ | 167,608 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-13 21:09:20 |
合計ジャッジ時間 | 3,563 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
ソースコード
#include<bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; ll n; inline bool check(ll m){ if(m*(m+1)/2>n){ return 1; } return 0; } int main(){ cin>>n; ll ok=1,ng=2*(ll)1e9; while(ng-ok>1){ ll mid=(ok+ng)/2; //cerr<<mid<<endl; if(check(mid)){ ng=mid; }else ok=mid; } if(ok*(ok+1)==2*n){ cout<<"YES"<<endl; cout<<ok<<endl; }else{ cout<<"NO"<<endl; } return 0; }