結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-02-09 22:31:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 403 bytes |
コンパイル時間 | 1,297 ms |
コンパイル使用メモリ | 158,428 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 20:45:12 |
合計ジャッジ時間 | 3,092 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%lld",&a); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define INF 2000000007LL using namespace std; typedef long long ll; typedef pair<int,int> P; ll a; ll C(ll v){ ll a1=v; a1*=(v+1LL); return a1/2LL; } int main(void){ scanf("%lld",&a); ll l=0,r=INF; while(l+1LL<r){ ll mid=(l+r)/2LL; if(C(mid)<=a)l=mid; else r=mid; } if(C(l)==a){ printf("YES\n"); printf("%lld\n",l); }else{ printf("NO\n"); } return 0; }