結果
問題 | No.542 1円玉と5円玉 |
ユーザー |
![]() |
提出日時 | 2017-12-21 08:36:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 548 bytes |
コンパイル時間 | 587 ms |
コンパイル使用メモリ | 66,928 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-17 20:40:09 |
合計ジャッジ時間 | 1,086 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> using namespace std; int judge[101][101] = {}; int A=0; int B=0; vector<int> ans; void dfs(int a, int b){ if(a>A|| b>B|| judge[a][b] == 1){ return; } if((1*a+5*b) !=0){ ans.push_back(1*a+5*b); } judge[a][b] =1; dfs(a+1,b); dfs(a,b+1); } int main() { cin>>A>>B; dfs(0,0); sort(ans.begin(),ans.end()); ans.erase(unique(ans.begin(),ans.end()),ans.end()); for(int i=0; i<ans.size(); i++){ cout<<ans[i]<<endl; } return 0; }