結果

問題 No.222 引き算と足し算
ユーザー shi-mo
提出日時 2016-10-27 01:56:40
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 363 bytes
コンパイル時間 8,140 ms
コンパイル使用メモリ 296,660 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 04:43:49
合計ジャッジ時間 9,072 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.string;
import std.regex;
import std.conv;

void main() {
    string s = readln.strip;

    auto m = match(s, r"^([+-]?[0-9]+)([+-])([+-]?[0-9]+)$");
    int x = m.captures[1].to!int;
    int y = m.captures[3].to!int;
    string op = m.captures[2];

    if ("+" == op) {
        writeln(x-y);
        return;
    }
    writeln(x+y);
}
0