結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2015-06-04 03:40:43 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 5,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 4,490 ms |
コンパイル使用メモリ | 74,328 KB |
実行使用メモリ | 41,108 KB |
最終ジャッジ日時 | 2024-12-23 01:45:20 |
合計ジャッジ時間 | 3,960 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
import java.util.Arrays;import java.util.LinkedList;import java.util.Scanner;public class Main {public static void main(String[] args){Scanner sc = new Scanner(System.in);char[] inputs = sc.next().toCharArray();int pos = 0;int current = 0;while('0' <= inputs[pos] && inputs[pos] <= '9'){current *= 10;current += Character.getNumericValue(inputs[pos]);pos++;}while(pos < inputs.length){boolean plus = inputs[pos++] == '*';int snd = 0;while(pos < inputs.length && '0' <= inputs[pos] && inputs[pos] <= '9'){snd *= 10;snd += Character.getNumericValue(inputs[pos]);pos++;}if(plus){current += snd;}else{current *= snd;}}System.out.println(current);}}