結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-13 17:29:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 520 bytes |
| コンパイル時間 | 586 ms |
| コンパイル使用メモリ | 27,136 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-13 17:29:54 |
| 合計ジャッジ時間 | 1,243 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d", &val);
| ~~~~~^~~~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>
int main()
{
// 計算式の数
int val;
scanf("%d", &val);
// 計算式のデータ
int x, y, ans;
scanf("%d %d", &x, &y);
// 計算結果が0以下になる場合は-1を出力
ans = y - x;
if (ans <= 0)
{
printf("-1\n");
return 0;
}
// 前の式と答えが同じでない場合は-1を出力
for (int i = 1; i < val; i++)
{
scanf("%d %d", &x, &y);
if (ans + x != y)
{
printf("-1\n");
return 0;
}
}
// □に入る数字を出力
printf("%d\n", ans);
return 0;
}
sasa