結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-05 23:48:09 |
| 言語 | Java (openjdk 27.0.1.0.3 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 129 ms / 1,000 ms |
| + 979µs | |
| コード長 | 721 bytes |
| 記録 | |
| コンパイル時間 | 1,891 ms |
| コンパイル使用メモリ | 95,904 KB |
| 実行使用メモリ | 47,996 KB |
| 最終ジャッジ日時 | 2026-11-13 11:18:16 |
| 合計ジャッジ時間 | 8,885 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.MatchResult;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
String str = sc.next();
Scanner s = new Scanner(str);
s.findInLine("([+-]?\\d+)([+-])([+-]?\\d+)");
MatchResult result = s.match();
int n1 = Integer.parseInt(result.group(1));
int n2 = Integer.parseInt(result.group(3));
String sign = result.group(2);
if (sign.equals("+")) {
System.out.println(n1 - n2);
}
else {
System.out.println(n1 + n2);
}
}
}