結果
| 問題 | No.193 筒の数式 |
| コンテスト | |
| ユーザー |
kusukusu0511
|
| 提出日時 | 2015-04-30 23:41:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,016 bytes |
| 記録 | |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 59,128 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 17:15:42 |
| 合計ジャッジ時間 | 1,167 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <string.h>
#include <algorithm>
int main(void){
int a,b,c;
char s[50];
char s1[50]="";
std::string s2;
int total,cnt;
int max=-100000000;
std::cin>>s;
for(int i=0; i<strlen(s); i++){
for(int k=i,a=0; a<strlen(s); a++,k++){
k%=strlen(s);
s1[a]=s[k];
}
if(s1[0]!='+' && s1[0]!='-' && s1[strlen(s)-1]!='+' && s1[strlen(s)-1]!='-'){
b=0;
while(s1[b]>='0' && s1[b]<='9'){
s2+=s1[b];
b++;
}
b--;
total= std::atoi(s2.c_str());
s2="";
for(int k=b; k<strlen(s1); k++){
if(s1[k]=='+'){
k++;
while(s1[k]>='0' && s1[k]<='9'){
s2+=s1[k];
k++;
}
k--;
c=std::atoi(s2.c_str());
s2="";
total+=c;
}
else if(s1[k]=='-'){
k++;
while(s1[k]>='0' && s1[k]<='9'){
s2+=s1[k];
k++;
}
k--;
c=std::atoi(s2.c_str());
s2="";
total-=c;
}
}
max=std::max(max,total);
}
}
std::cout<<max<<std::endl;
}
kusukusu0511