結果

問題 No.185 和風
コンテスト
ユーザー mosmos_21
提出日時 2016-10-12 22:32:59
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 302 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 28,872 KB
最終ジャッジ日時 2026-02-23 22:32:42
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:4:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |   scanf("%d%d%d", &n, &x, &y);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:11:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     scanf("%d%d", &x, &y);
      |     ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include<stdio.h>
int main(){
  int n, x, y, a, i;
  scanf("%d%d%d", &n, &x, &y);
  a = y - x;
  if(a < 1){
    printf("-1\n");
    return 0;
  }
  while(--n){
    scanf("%d%d", &x, &y);
    i  = y - x;
    if(a != i){
      printf("-1\n");
      return 0;
    }
  }
  printf("%d\n", a);
  return 0;
}
0