結果

問題 No.2132 1 or X Game
ユーザー lddlinanlddlinan
提出日時 2023-03-30 16:34:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,616 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 84,508 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-22 02:28:45
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 95 ms
4,348 KB
testcase_02 AC 94 ms
4,348 KB
testcase_03 AC 75 ms
4,348 KB
testcase_04 AC 96 ms
4,372 KB
testcase_05 AC 96 ms
4,372 KB
testcase_06 AC 95 ms
4,372 KB
testcase_07 AC 95 ms
4,372 KB
testcase_08 AC 95 ms
4,372 KB
testcase_09 AC 59 ms
4,372 KB
testcase_10 AC 85 ms
4,372 KB
testcase_11 AC 82 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};



char dp[10000];
int main() {
    int i;
    LL n, x, r, c, m;
    int tc; scanf("%d", &tc); while(tc) { tc--;
        scanf("%lld %lld", &n, &x);
        if (x&1) {
            r=(n+1)/2;
        } else {
            if (n<x) r=(n+1)/2;
            else {
                r=(x-2)/2;
                n-=(x-2);
                c=n/(x+3);
                r+=c*(x+4)/2;
                n%=(x+3);
                if (n) r++;
                r+=n/2;
            }
            /*
            dp[0]=0;
            for (i=1; i<x&&i<=n; i++) dp[i]=i&1;
            dp[i++]=1;
            for (; i<=n&&i<x+x; i++) {
                if (dp[i-1]==0) dp[i]=1;
                else dp[i]=0;
            }
            for (; i<=n; i++) {
                if (dp[i-1]==0) dp[i]=1;
                else {
                    if (dp[i-x-2]) dp[i]=0;
                    else {
                        if (i-x-x-2<0||dp[i-x-x-2]) dp[i]=1;
                        else dp[i]=0;
                    }
                }

            }
            for (i=0; i<=n; i++) printf("%d ", dp[i]); printf("\n");
            */
        }
        printf("%lld\n", r%998244353);
    }
    return 0;
}
0