結果

問題 No.193 筒の数式
ユーザー aaaaaaiu
提出日時 2019-08-08 13:18:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 195,372 KB
最終ジャッジ日時 2025-01-07 11:00:54
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 6 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    string s;
    cin>>s;
    int n=s.size();
    int mx=-100000000;
    for (int i=0;i<n;i++) {
        string t=s.substr(i)+s.substr(0,i);
        if (!isdigit(t[0])) continue;
        int ans=0;
        while (i<n && isdigit(t[i])) {
            ans=10*ans+t[i]-'0';
            i++;
        }
        while (i < n) {
            int sign=1;
            if (t[i]=='-') sign=-1;
            i++;
            if (i==n) goto invalid;
            int num=0;
            while (i<n && isdigit(t[i])) {
                num=10*num+t[i]-'0';
                i++;
            }
            ans+=num*sign;
        }
        mx=max(mx,ans);
        invalid:;
    }
    cout<<mx<<endl;
    return 0;
}
0