結果
問題 |
No.193 筒の数式
|
ユーザー |
![]() |
提出日時 | 2015-04-28 18:09:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,389 bytes |
コンパイル時間 | 470 ms |
コンパイル使用メモリ | 60,812 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-05 05:02:28 |
合計ジャッジ時間 | 1,138 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 12 |
ソースコード
#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; }