結果
| 問題 | No.2132 1 or X Game |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-25 22:01:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,587 bytes |
| 記録 | |
| コンパイル時間 | 2,054 ms |
| コンパイル使用メモリ | 213,364 KB |
| 最終ジャッジ日時 | 2025-02-09 00:13:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 10 |
ソースコード
#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";
}
}