結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
koukonko
|
| 提出日時 | 2015-12-13 03:24:13 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,129 bytes |
| 記録 | |
| コンパイル時間 | 1,825 ms |
| コンパイル使用メモリ | 81,928 KB |
| 実行使用メモリ | 46,720 KB |
| 最終ジャッジ日時 | 2026-04-04 19:22:51 |
| 合計ジャッジ時間 | 8,585 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 TLE * 1 -- * 8 |
ソースコード
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
try {
int N = Integer.parseInt(read.readLine());
int total = Integer.parseInt(read.readLine());
boolean[] flag = new boolean[N - 1];
String[] box = read.readLine().split(" ");
int[] num = new int[N];
for (int i = 0; i < N; ++i) {
num[i] = Integer.parseInt(box[i]);
}
int count = (int) Math.pow(2, N - 1);
for (int i = 0; i < count; ++i) {
int pro = num[0];
for (int j = 0; j < N - 1; ++j) {
if (flag[j] == false) {
pro += num[j + 1];
} else {
pro *= num[j + 1];
}
}
if (total == pro) {
for (int j = 0; j < N - 1; ++j) {
if (flag[j] == false) {
System.out.print('+');
} else {
System.out.print('*');
}
}
break;
} else {
int s = 0;
while (flag[s]) {
flag[s] = false;
++s;
}
flag[s] = true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
koukonko