結果

問題 No.3308 One-time Changed Formula
コンテスト
ユーザー GOTKAKO
提出日時 2025-10-24 21:31:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 1,823 ms
コンパイル使用メモリ 195,136 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-24 21:31:29
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while(T--){
        int N; cin >> N;
        string s; cin >> s;
        int answer = 0;
        bool plus = true;
        for(auto c : s){
            if(c == '+'){
                if(plus) answer += 9;
                plus = true;
            }    
            else if(c == '-'){
                if(plus) answer += 9;
                plus = false;
            }    
            else if(c == '*'){
                if(plus) answer += 9;
            }
            else{
                if(plus) answer += 9-(c-'0');
                else answer += c-'0'-1;
            }
        }
        cout << answer << "\n";
    }
}
0