結果
問題 | No.10 +か×か |
ユーザー | tottoripaper |
提出日時 | 2014-11-16 03:47:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,065 bytes |
コンパイル時間 | 502 ms |
コンパイル使用メモリ | 52,676 KB |
実行使用メモリ | 13,504 KB |
最終ジャッジ日時 | 2023-08-30 07:07:14 |
合計ジャッジ時間 | 1,286 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
13,204 KB |
testcase_01 | AC | 10 ms
13,196 KB |
testcase_02 | AC | 10 ms
13,208 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 9 ms
13,136 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 13 ms
13,208 KB |
testcase_10 | AC | 10 ms
13,136 KB |
testcase_11 | AC | 10 ms
13,280 KB |
ソースコード
#include<cstdio> #include<iostream> int N, total, A[50]; bool can[50][100001]; char ope[50][100001]; int main(){ scanf("%d %d", &N, &total); for(int i=0;i<N;i++){scanf("%d", A+i);} std::fill(&can[0][0], &can[0][0]+50*100001, false); std::fill(&ope[0][0], &ope[0][0]+50*100001, 0); can[0][A[0]] = true; for(int i=0;i<N-1;i++){ for(int j=0;j<=total;j++){ if(!can[i][j]){continue;} if(j * A[i+1] <= total && ope[i+1][j*A[i+1]] != '+'){ can[i+1][j*A[i+1]] = true; ope[i+1][j*A[i+1]] = '*'; } if(j + A[i+1] <= total){ can[i+1][j+A[i+1]] = true; ope[i+1][j+A[i+1]] = '+'; } } } char opes[50]; int length = 0; for(int i=N-1;i>0;i--){ opes[length++] = ope[i][total]; if(ope[i][total] == '+'){total -= A[i];} else{total /= A[i];} } for(int i=length-1;i>=0;i--){ putchar(opes[i]); } puts(""); }