結果
問題 |
No.265 数学のテスト
|
ユーザー |
![]() |
提出日時 | 2015-08-08 23:41:58 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,246 bytes |
コンパイル時間 | 1,961 ms |
コンパイル使用メモリ | 78,340 KB |
実行使用メモリ | 59,800 KB |
最終ジャッジ日時 | 2024-07-18 06:06:27 |
合計ジャッジ時間 | 8,331 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 1 |
ソースコード
package tmp; import java.util.Scanner; public class Main { static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); solve(); } static int i; static String s; static int n; static int[] scan(){ int d[] = new int[n]; for(int j = 0;j < n;j++)d[j] = 0; int tn = 0; int tv = 0; while(true){ String nx; if(i < s.length()){ nx = s.substring(i, i + 1) ; }else{ nx = "end"; } if(nx.equals("x")){ if(tv == 0)tv = 1; tn++; }else if(nx.equals("*")){ }else if(nx.equals("}") || nx.equals("end") || nx.equals("+")){ d[tn] += tv; tn = 0; tv = 0; if(nx.equals("}"))break; }else if(i < s.length()-1 && s.substring(i, i + 2).equals("d{")){ i += 2; int tmp[] = scan(); for(int j = 1;j < n;j++){ d[j-1] += tmp[j] * j; } }else { if(tv == 0)tv = 1; tv *= Integer.parseInt(nx); } i++; if(nx.equals("end"))break; } return d; } static void solve(){ int l = sc.nextInt(); n = sc.nextInt(); n++; s = sc.next(); int[] d = new int[n]; i = 0; d = scan(); for(int j = 0;j < n;j++){ System.out.print(d[j]); System.out.print(" "); } System.out.println(); } }