結果

問題 No.193 筒の数式
ユーザー kusukusu0511kusukusu0511
提出日時 2015-04-28 18:09:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,389 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 62,012 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-18 14:05:47
合計ジャッジ時間 1,368 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string.h>
#include <algorithm>

int main(void){
	int a,b,d;
	int total=0;
	int max=-1000000;
	char s[50];
	char s1[50]= "";
	std::string s2;
	int cnt=0;
	int c=0;

	std::cin>>s;

	for(int j=0; j<strlen(s); j++){
	
		for(int i=0; i<strlen(s); i++){
			if(i<j){
				for(int k=0; k<i; k++)s1[k]=s[k];
				for(int k=i; k<j; k++)s1[k+1]=s[k];
				s1[i]=s[j];
				for(int k=j+1; k<strlen(s); k++)s1[k]=s[k];
			}	
						
			else{
				for(int k=0; k<j; k++)s1[k]=s[k];
					
				for(int k=j; k<i; k++){
					s1[k]=s[k+1];
				}

					
				s1[i]=s[j];
				for(int k=i+1; k<strlen(s); k++)s1[k]=s[k];
			}

			if(s1[0]!='+' && s1[0]!='-' && s1[strlen(s1)-1]!='+' && s1[strlen(s1)-1]!='-'){
					c=0;
					while(s1[c]>='0'&& s1[c]<='9'){
							
							s2+=s1[c];
							c++;
					}
					c--;
					total=std::atoi(s2.c_str());
					s2="";

					for(int a=c; a<strlen(s1); a++){
						if(s1[a]=='+'){
							a++;
							while(s1[a]>='0'&& s1[a]<='9'){
								s2+=s1[a];
								a++;
							}
							d=std::atoi(s2.c_str());
							s2="";
							total+=d;
							a--;
						}

						else if(s1[a]=='-'){
							a++;
							while(s1[a]>='0'&& s1[a]<='9'){
								s2+=s1[a];
								a++;
							}
							d=std::atoi(s2.c_str());
							s2="";
							total-=d;
							a--;
						}					

		
					}

				max=std::max(max,total);
			}			
		}
	}
	std::cout<<max<<std::endl;
}
0