結果
| 問題 | 
                            No.2132 1 or X Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-11-25 21:56:34 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 764 bytes | 
| コンパイル時間 | 678 ms | 
| コンパイル使用メモリ | 67,100 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-02 04:31:21 | 
| 合計ジャッジ時間 | 7,809 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | WA * 11 | 
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
long N,X;
main()
{
	int T;cin>>T;
	for(;T--;)
	{
		cin>>N>>X;
		N++;
		if(X%2==1)cout<<mint(N/2).val()<<"\n";
		else
		{
			mint ans=0;
			if(X+1<=N/X)
			{
				long t=X*(X+1);
				ans+=N/t*(X/2*(X+2));
				N%=t;
			}
			if(N<=X)ans+=N/2;
			else
			{
				N-=X;
				ans+=X/2;
				if(N<=X)ans+=(N+1)/2;
				else
				{
					N-=X;
					ans+=X/2;
					long t=N/X;
					ans+=2*t;
					ans+=t;
					ans+=(t+1)/2;
					N%=X;
					//t,t+1 -> O
					//t,t-2,t-4,...
					if(N<=t+1)
					{
						if(t%2==0)ans+=(N+1)/2;
						else ans+=N/2;
					}
					else
					{
						ans+=(t+2)/2;
						N-=t+1;
						ans+=(N+1)/2;
					}
				}
			}
			cout<<ans.val()<<"\n";
		}
	}
}