UV 1567, lga1567
Link to the Q & A 1567-A simple stone game
Given K and N, it indicates that a pile of stones have N. The first time you can get 1 ~ N-1 stone, get the last stone victory, word each operation, the number of stones can not exceed the opponent's last take the stone m K times. Ask if you can win the first hand and output the smallest first operation.
Solution: After thinking about this question for a day, I made a table to find the rule, and I pushed the formula. I couldn't help it. Then I found an answer on the Internet, which will be very clear, solution book
/******************* K times dynamic subtraction game * Reference: explain <cstdio> # include <cstring> # include <algorithm> using namespace std; const int maxn = 1e6 + 5; int N, K, a [maxn], B [maxn]; int main () {int cas; scanf ("% d", & cas); for (int I = 1; I <= cas; I ++) {scanf ("% d", & N, & K); int p = 0, q = 0; a [0] = B [0] = 0; while (a [p] <N) {a [p + 1] = B [p] + 1; p ++; while (a [q + 1] * K <a [p]) q ++; B [p] = B [q] + a [p];} printf ("Case % d:", I); if (N = a [p]) printf ("lose \ n"); else {int ans; while (N) {if (N> = a [p]) {N-= a [p]; ans = a [p];} p --;} printf ("% d \ n", ans) ;}} return 0 ;}
Coreldraw x5 activation code
The installation code you provided cannot be changed.
Installation code: X6FH-3J45-TT7X-J567-RAS8
Serial: DR15R22-DS48YWY-MUDYDGJ-WX7THLY
Activation code: 5876-0C27-1432-0F59-1567
Try it!