結果
| 問題 |
No.3308 One-time Changed Formula
|
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2025-10-27 17:10:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 573 bytes |
| コンパイル時間 | 1,399 ms |
| コンパイル使用メモリ | 163,328 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-27 17:10:57 |
| 合計ジャッジ時間 | 2,846 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;
int main(){
int t;
cin >> t;
rep(ti, 0, t) {
int n;
string s;
cin >> n >> s;
int ans = 0, sf = 0;
rep(i, 0, n) {
if(isdigit(s[i])) {
int d = s[i] - '0';
if(sf) ans += d - 1;
else ans += 9 - d;
}
else if(s[i] == '*') {
if(sf == 0) ans += 9;
}
else if(s[i] == '-') {
if(sf == 0) ans += 9;
sf = 1;
}
else if(s[i] == '+') {
if(sf == 0) ans += 9;
sf = 0;
}
}
cout << ans << endl;
}
}
forest3