結果

問題 No.193 筒の数式
ユーザー kyuridenamidakyuridenamida
提出日時 2015-04-26 22:12:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 147,156 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 11:54:35
合計ジャッジ時間 2,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main(){
	string s;
	int x;
	long long ans = 0;

	cin >> s;
	for(int i = 0 ; i < 2*s.size() ; i++){
		try{
			if( s[0] == '+' || s[0] == '-' ) throw "";
			if( s[s.size()-1] == '+' || s[s.size()-1] == '-' ) throw "";
			
			int r = 0;
			int now;
			
			for(int j = 0 ; j+1 < s.size() ; j++){
				if( s[j] == s[j+1] && (s[j] == '+'||s[j]=='-') ) throw "";
				
			}
			int p = 1;
			//cout << s << endl;
			for(int j = 0 ; j < s.size() ; ){
				int now = 0;
				int k = j;
				while( s[k] >= '0' && s[k] <= '9' )
					now = now * 10 + s[k++] - '0';
				r += p * now;
				if( s[k++] == '-' ) p = -1;
				else p = 1;
				j = k;
			}
			ans = max(ans,r);
		}catch(const char *msg){
			
		}
		rotate(s.begin(),s.begin()+1,s.end());
	}
	cout << ans << endl;
	
}
0