結果
| 問題 | 
                            No.257 N言っちゃダメゲーム (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lunnear
                         | 
                    
| 提出日時 | 2019-02-18 06:42:22 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 430 bytes | 
| コンパイル時間 | 137 ms | 
| コンパイル使用メモリ | 22,400 KB | 
| 実行使用メモリ | 25,476 KB | 
| 平均クエリ数 | 2.07 | 
| 最終ジャッジ日時 | 2024-07-16 16:40:02 | 
| 合計ジャッジ時間 | 3,295 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 3 WA * 27 | 
コンパイルメッセージ
main.cpp: In function ‘int q(int)’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d", &ret);
      |     ~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int q(int val)
{
    printf("%d\n", val);
    fflush(0);
    
    int ret;
    scanf("%d", &ret);
    
    return ret;
}
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    
    int put = (n - 1) % (k + 1);
    int prev = put;
    int get = q(put);
    
    while(get < n)
    {
        put = get - prev;
        put = (k + 1) - put;
        prev = get;
        get = q(put);
    }
    
    return 0;
}
            
            
            
        
            
lunnear