結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
|
提出日時 | 2019-10-12 14:40:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 269 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 71,808 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 22:31:45 |
合計ジャッジ時間 | 2,875 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<set> using namespace std; set<int>S; main() { for(int i=1;i*(i+1)/2<=10000000;i++)S.insert(i*(i+1)/2); int N;cin>>N; int ans=3; for(int s:S) { if(N==s) { ans=1; } if(ans==3&&S.find(N-s)!=S.end())ans=2; } cout<<ans<<endl; }