結果

問題 No.542 1円玉と5円玉
ユーザー Yut176Yut176
提出日時 2017-07-20 12:57:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 103,104 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 05:49:26
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<random>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int A, B;
vector<bool> x;

int dfs(int a, int b){

  if( x[ A-a + 5*(B-b) ] ) return 0;
  x[ A-a + 5*(B-b) ] = true;

  if( a == 0 && b == 0 ) return 1;

  if( a != 0 ) dfs(a-1, b);
  if( b != 0 ) dfs(a, b-1);

  return 0;
}

int main(void) {
  cin >> A >> B;
  x.resize(A + 5*B + 1, false);
  dfs(A, B);
  for(int i=1; i<x.size(); i++){
    if( x[i] ) cout << i << endl;
  }

  return 0;
}





// EOF
0