結果

問題 No.3788 Floor Sum Queries
コンテスト
ユーザー yuunegi
提出日時 2026-11-06 23:33:34
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 1,044 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,759 ms
コンパイル使用メモリ 380,476 KB
実行使用メモリ 9,792 KB
平均クエリ数 5.00
最終ジャッジ日時 2026-11-06 23:33:42
合計ジャッジ時間 6,877 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
int main(void){
    int t;
    cin>>t;
    while(t--){
        long long a,b;
        cout<<"? 1000000 1000000"<<endl;
        cin>>a;
        if(a==-1)return 1;
        cout<<"? 1000000 0"<<endl;
        cin>>b;
        if(b==-1)return 1;
        long long val=a-b;
        if(val==1){
            cout<<"! 1"<<endl;
            continue;
        }
        
        vector<long long>ans;
        for(long long i=2*b/(val+1)+1;i<=2*b/(val-1)+1;i++){
            if(i>1e6)break;
            long long tmp=(1000000*i)/val;
            if(tmp==0||tmp>1e6)continue;
            if(i*1000000/tmp!=val)continue;
            if(floor_sum(i,tmp,1000000,0)!=b)continue;
            ans.push_back(i);
        }
        if(ans.size()==1){
            cout<<"! "<<ans[0]<<endl;
        }else{
            for(int i=0;i<ans.size();i++){
               cerr<<ans[i]<<" ";
            }
            cerr<<endl;
            return 1;
        }
    }
    return 0;
}
0