結果
問題 |
No.648 お や す み
|
ユーザー |
|
提出日時 | 2018-03-24 17:10:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 355 bytes |
コンパイル時間 | 416 ms |
コンパイル使用メモリ | 30,720 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-13 21:18:54 |
合計ジャッジ時間 | 2,311 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 84 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> //1...n //S(n)=(n+1)*n/2 long long int n; int main(){ scanf("%lld",&n); //n*n < n*(n+1) <(n+1)*(n+1) for(long long int m = (int)sqrt(2*n) ; m*(m+1) <= 2*n; m++){ if(m*(m+1)==2*n){ puts("YES"); printf("%lld\n",m); return 0; } } puts("NO"); }