結果

問題 No.193 筒の数式
ユーザー notetonousnotetonous
提出日時 2016-04-29 00:15:26
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 05:17:14
合計ジャッジ時間 741 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 0 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |   ^~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0