結果

問題 No.2357 Guess the Function
ユーザー HIcoderHIcoder
提出日時 2023-06-26 00:06:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 1,000 ms
コード長 984 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 80,128 KB
実行使用メモリ 24,312 KB
平均クエリ数 2.91
最終ジャッジ日時 2023-09-15 14:21:56
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
23,412 KB
testcase_01 AC 23 ms
23,412 KB
testcase_02 AC 23 ms
23,376 KB
testcase_03 AC 22 ms
23,652 KB
testcase_04 AC 23 ms
24,312 KB
testcase_05 AC 22 ms
24,036 KB
testcase_06 AC 22 ms
23,520 KB
testcase_07 AC 23 ms
23,640 KB
testcase_08 AC 23 ms
23,412 KB
testcase_09 AC 22 ms
23,988 KB
testcase_10 AC 22 ms
23,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:58:21: 警告: ‘A’ may be used uninitialized [-Wmaybe-uninitialized]
   58 |      cout<<"! "<<A<<' '<<B<<endl;
      |                     ^~~
main.cpp:42:13: 備考: ‘A’ はここで定義されています
   42 |         int A,B;
      |             ^

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;

int main(){

    int x0=100;
    cout<<"? "<<x0<<endl;
    int a0,a1;
    cin>>a0;

  
    
    if(a0==99){
        int A,B;
        A=99;
        B=100;

        cout<<"! "<<A<<' '<<B<<endl;
        return 0;
    }
    else{
        
        int x1=100-a0-1;
        cout<<"? "<<x1<<endl;
        cin>>a1;//f(100-a0-1)=B-1

        
        int A,B;

        B=(a1+1);
        for(int a=0;a<=100;a++){
            /*
            if((x1+a)%B==B-1){
                A=a;
                break;
            }
            */
            if((x0+a)%B==a0){
                A=a;
                break;
            }
        }

     cout<<"! "<<A<<' '<<B<<endl;
    }
    
     return 0;


}
0