結果
問題 |
No.10 +か×か
|
ユーザー |
![]() |
提出日時 | 2014-11-11 12:30:17 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 5,138 ms |
コンパイル使用メモリ | 77,644 KB |
実行使用メモリ | 118,936 KB |
最終ジャッジ日時 | 2024-12-31 09:37:53 |
合計ジャッジ時間 | 27,910 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 2 TLE * 4 |
ソースコード
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); } return; } 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>()); } }