結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2014-11-11 12:37:01 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 2,629 ms |
| コンパイル使用メモリ | 78,164 KB |
| 実行使用メモリ | 109,844 KB |
| 最終ジャッジ日時 | 2024-12-31 09:38:42 |
| 合計ジャッジ時間 | 17,055 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 WA * 1 TLE * 2 |
ソースコード
import java.util.*;
public class Main {
static int N;
static int T;
static int[] a;
static void dfs(int now,int sum,ArrayList<Character> result ){
if(now==N-1){
if(sum==T){
for(char g:result){
System.out.print(g);
}
System.exit(0);
}
return;
}
if(sum>=T) return;
result.add('+');
dfs(now+1,sum+a[now+1],result);
result.remove(result.size()-1);
result.add('*');
dfs(now+1,sum*a[now+1],result);
result.remove(result.size()-1);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
T = sc.nextInt();
a = new int[N];
for(int i=0;i<N;i++){
a[i] = sc.nextInt();
}
dfs(0,a[0],new ArrayList<Character>());
}
}
kou6839