結果

問題 No.2132 1 or X Game
ユーザー KKT89KKT89
提出日時 2022-11-25 22:01:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,587 bytes
コンパイル時間 2,673 ms
コンパイル使用メモリ 207,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 03:11:35
合計ジャッジ時間 5,514 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 110 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myrand(ll B){
    return (unsigned long long) rng() % B;
}

constexpr ll mod = 998244353;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

void add(int &x,int y){
    x += y;
    if(x >= mod) x -= mod;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    for(int i=0;i<10;i++){
//        int n = myrand(30)+1, x = myrand(n)+1;
//        map<pair<int,pair<int,int>>,bool> mp;
//        auto slv = [&](auto self,int cur,int a,int b)->bool{
//            if(mp.find({cur,{a,b}}) != mp.end()){
//                return mp[{cur,{a,b}}];
//            }
//            bool res = false;
//            if(cur == 0) return false;
//            if(!self(self, cur-1, b, 0)){
//                res = true;
//            }
//            if(cur >= x and !a and !self(self, cur-x, b, 1)){
//                res = true;
//            }
//            mp[{cur,{a,b}}] = res;
//            return res;
//        };
//        cout << n << " " << x << endl;
//        for(int i=1;i<=n;i++){
//            cout << "i = " << i << " " << slv(slv,i,0,0) << endl;
//        }
//    }
    int q; cin >> q;
    while(q--){
        ll n,x; cin >> n >> x;
        ll res = (n+1)/2;
        ll ad = n/x - n/(2*x);
        if(x%2 == 0) res += ad;
        cout << res%mod << "\n";
    }
}
0