結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
holeguma
|
| 提出日時 | 2015-08-11 23:30:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 5,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 2,170 ms |
| コンパイル使用メモリ | 74,776 KB |
| 実行使用メモリ | 37,240 KB |
| 最終ジャッジ日時 | 2024-12-23 01:46:24 |
| 合計ジャッジ時間 | 2,980 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
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();
}
}
}
holeguma