結果

問題 No.185 和風
ユーザー umashikaumashika
提出日時 2016-02-01 22:23:14
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 437 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 20,576 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 18:35:20
合計ジャッジ時間 738 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c:11:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d %d",&x,&y);
      |   ^~~~~~~~~~~~~~~~~~~~
main.c:16:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     scanf("%d %d",&x,&y);
      |     ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main(void)
{
  int i,n;
  int x,y,z;
  int dif = 0;
  int flag = 0;
  scanf("%d",&n);

  //最初の差を基準にする
  scanf("%d %d",&x,&y);
  dif=y-x;

  //2番目から最後までを確認する
  for(i=1;i<n;i++){
    scanf("%d %d",&x,&y);
    if((y-x)!=dif || y-x<=0){
      flag = 1;
      break;
    }
  }
  if(!flag){
    printf("%d\n",dif);
  }
  else{
    printf("-1\n");
  }
  return 0;
}










0