結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
notetonous
|
| 提出日時 | 2016-04-29 00:28:43 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 120 ms |
| コンパイル使用メモリ | 21,888 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-04 17:31:47 |
| 合計ジャッジ時間 | 927 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%s",s);
| ^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
int main(){
char s[21];
int i,j;
int len;
int ans;
int max=-10000000;
int x;
int flag=0;//0 plus 1 minus
int ch=1;
scanf("%s",s);
len=strlen(s);
for(i=len;i<len+len-1;i++)s[i]=s[i-len];
s[i]='\0';
for(i=0;i<len;i++){
x=0;ans=0;flag=0;ch=1;
for(j=i;j<i+len;j++){
if(s[i]=='+' || s[i]=='-' || s[i+len-1]=='+' || s[i+len-1]=='-') ch=0;
else{
if(s[j]=='+'){
if(flag==0)ans+=x;
else ans-=x;
x=0;flag=0;
}
else if(s[j]=='-'){
if(flag==0)ans+=x;
else ans-=x;
x=0;flag=1;
}
else x=x*10+(s[j]-48);
}
}
if(ch==1){
if(flag==0)ans+=x;
else ans-=x;
if(max < ans)max=ans;
}
}
printf("%d\n",max);
return 0;
}
notetonous