結果
| 問題 | No.3084 Identify f(x) |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2025-04-08 14:53:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 521 bytes |
| 記録 | |
| コンパイル時間 | 376 ms |
| コンパイル使用メモリ | 39,552 KB |
| 実行使用メモリ | 25,856 KB |
| 平均クエリ数 | 3.00 |
| 最終ジャッジ日時 | 2025-04-08 14:53:28 |
| 合計ジャッジ時間 | 1,668 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp: In function ‘int query(int)’:
main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d", &f);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 3084.cc: No.3084 Identify f(x) - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
/* typedef */
/* global variables */
/* subroutines */
int query(int x) {
printf("? %d\n", x); fflush(stdout);
int f;
scanf("%d", &f);
return f;
}
/* main */
int main() {
int f0 = query(0), f1 = query(1);
// f0=a*0+b=b, f1=a*1+b=a+b
// -> b=f0, a=f1-b=f1-f0
int a = f1 - f0, b = f0;
printf("! %d %d\n", a, b); fflush(stdout);
return 0;
}
tnakao0123