結果

問題 No.1770 N言っちゃダメゲーム (6)
ユーザー norikamenorikame
提出日時 2021-12-02 17:50:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 204,860 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-18 10:24:08
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

int main() {
	int n, k;
	cin >> n >> k;
	bool pat = false;
	if ((k+1)%2 == 1) pat = true;
	else {
		int pcnt = 0, tval = k+1;
		while (tval%2 == 0) {
			tval /= 2;
			++pcnt;
		}
		if (pcnt%2 == 0) pat = true;
	}
	vector<int> res;
	int wval = (n-1) % (k+1);
	if (pat) {
		if (wval == 0) res.push_back(0);
		else {
			res.push_back(wval);
			if (wval%2==0 && (wval/2+(k+1))%2==1) res.push_back(wval/2);
		}
	}
	else {
		if (wval == 0) {
			if (k+1 == n-1) res.push_back(0);
			else res.push_back(k);
		}
		else if (wval == 1) {
			if ((n-2)/(k+1) <= 1) res.push_back(1);
			else res.push_back(0);
		}
		else {
			if ((n-wval-1)/(k+1) <= 1) res.push_back(wval);
			else {
				res.push_back(wval-1);
				if ((n-wval-1)/(k+1)<=2 && (wval-1)%2==0 && ((wval-1)/2+(k+2))%2==1) res.push_back((wval-1)/2);
				else if ((n-wval-1)/(k+1)>2 && (wval-1)%2==0 && ((wval-1)/2+(k+1))%2==1) res.push_back((wval-1)/2);
			}
		}
	}
	sort(all(res));
	for (int val : res) cout << val << endl;
	return 0;
}
0