Competition/codeforces
Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game
shyram
2019. 7. 17. 00:40
D. 1-2-K Game
https://codeforces.com/contest/1194/problem/D
게임이론 문제인것 같은데 내가 게임이론을 잘 모른다..
그래서 k값을 조정해가면서 패턴을 찾아보았다.
k가 3의 배수일때 특정한 주기가 있다는 것을 발견했고, 그 패턴은 L WW L WW ... L 처럼 나온다.
(직접 출력해보면 알 수 있음)
코드는 매우 간단함.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define rep(i, a, b) for(ll i=a; i<=b; i++) ll gcd(ll a, ll b) { while (b) { a %= b, swap(a, b); } return a; } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } #define MAXN 50050 #define PI 3.14159265358979323846 #define MOD 1000000000 ll n, m, k; ll a, b, c; string s, t, p; int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int q; cin >> q; rep(test, 1, q) { cin >> n >> k; if (k % 3) { if (n % 3 == 0) cout << "Bob\n"; else cout << "Alice\n"; } else { n = n % (k + 1); if (n % 3 || n == k) cout << "Alice\n"; else cout << "Bob\n"; } } return 0; } | cs |