結果
問題 | No.49 算数の宿題 |
ユーザー | holeguma |
提出日時 | 2015-08-11 23:30:04 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 1,790 ms |
コンパイル使用メモリ | 71,560 KB |
実行使用メモリ | 49,788 KB |
最終ジャッジ日時 | 2023-08-24 17:26:47 |
合計ジャッジ時間 | 2,857 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
49,400 KB |
testcase_01 | AC | 41 ms
49,220 KB |
testcase_02 | AC | 41 ms
49,308 KB |
testcase_03 | AC | 41 ms
49,368 KB |
testcase_04 | AC | 43 ms
49,788 KB |
testcase_05 | AC | 43 ms
49,292 KB |
testcase_06 | AC | 42 ms
49,276 KB |
testcase_07 | AC | 41 ms
49,284 KB |
testcase_08 | AC | 42 ms
49,564 KB |
testcase_09 | AC | 42 ms
49,272 KB |
ソースコード
import java.io.*; class Main{ static final PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null&&!line.isEmpty()){ int res=0; int num=0; char c=' '; for(int i=0;i<line.length();i++){ if(line.charAt(i)=='*'||line.charAt(i)=='+'){ if(c=='*') res+=num; if(c=='+') res*=num; if(c==' ') res=num; c=line.charAt(i); num=0; } else{ num=num*10+(int)(line.charAt(i)-'0'); if(i==line.length()-1){ if(c=='*') res+=num; if(c=='+') res*=num; } } } out.println(res); out.flush(); } } }