結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-02-10 19:31:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 440 bytes |
| コンパイル時間 | 1,281 ms |
| コンパイル使用メモリ | 159,400 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-07 19:55:58 |
| 合計ジャッジ時間 | 1,871 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int)’:
main.cpp:19:20: warning: control reaches end of non-void function [-Wreturn-type]
19 | dfs(x+1,r*a[x]);
| ~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int dn[55][100010];
int tot,N;
int a[55];
char res[55];
int dfs(int x,int r){
if( r > tot ) return 0;
if( dn[x][r]++ ) return 0;
if( r == tot && x == N ){
cout << res << endl;
exit(0);
}else{
if( N == x ) return 0;
res[x-1] = '+';
dfs(x+1,r+a[x]);
res[x-1] = '*';
dfs(x+1,r*a[x]);
}
}
int main(){
cin >> N >> tot;
for(int i = 0 ; i < N ; i++) cin >> a[i];
dfs(1,a[0]);
}
kyuridenamida