結果
問題 | No.222 引き算と足し算 |
ユーザー |
|
提出日時 | 2017-06-17 05:49:05 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 922 bytes |
コンパイル時間 | 663 ms |
コンパイル使用メモリ | 98,428 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 20:12:07 |
合計ジャッジ時間 | 1,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
import std.stdio, std.string, std.conv, std.algorithm; import std.range, std.array, std.container, std.math, std.typecons; immutable int mod = 10^^9 + 7; immutable int inf = 20000; string s; void main() { s = readln.chomp; int sgn = 1, value, ans, op; value = inf; foreach (ch ; s) { if (ch == '+' || ch == '-') { if (value == inf) { sgn = (ch == '+' ? 1 : -1); } else { op = (ch == '+' ? -1 : 1); ans = sgn * value; value = inf; sgn = 1; } } else { if (value == inf) { value = ch - '0'; } else { value = 10 * value + ch - '0'; } } } ans += op * sgn * value; writeln(ans); } bool is_uruu(int x) { return !(x % 400) || (x % 100 && !(x % 4)); }