結果
問題 |
No.2132 1 or X Game
|
ユーザー |
|
提出日時 | 2023-03-30 16:34:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 1,616 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 85,800 KB |
最終ジャッジ日時 | 2025-02-11 19:10:21 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | int tc; scanf("%d", &tc); while(tc) { tc--; | ~~~~~^~~~~~~~~~~ main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%lld %lld", &n, &x); | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }