結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-08 12:12:34 |
| 言語 | Java (openjdk 27.0.1.0.3 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 143 ms / 1,000 ms |
| + 600µs | |
| コード長 | 790 bytes |
| 記録 | |
| コンパイル時間 | 4,477 ms |
| コンパイル使用メモリ | 95,960 KB |
| 実行使用メモリ | 48,448 KB |
| 最終ジャッジ日時 | 2026-11-13 11:20:27 |
| 合計ジャッジ時間 | 10,931 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main_yukicoder222 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String xopy = sc.next();
String regex = "([+-]?\\d+)([+-])([+-]?\\d+)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(xopy);
if (m.find()) {
int x = Integer.parseInt(m.group(1));
String op = m.group(2);
int y = Integer.parseInt(m.group(3));
if (op.equals("+")) {
System.out.println(x - y);
} else {
System.out.println(x + y);
}
} else {
System.out.println("NG");
}
sc.close();
}
}