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