This problem is not difficult.
But I've been making jokes. Not the wrong question is the array opened small.
A,b,c,d are still very water, E is actually quite simple, but I did not want to understand.
C, enumerate all possible d, and the complexity is sort of nlogn
D, for the odd, Black can only have to go with the white symmetry to be sure to win
Even if the words, white to one step to become an odd number of cases, and then black to go, white Square on the line of symmetry. So at the end of the White party will win
E
For the given T, a, B
We'll get the special deal done.
Nothing but a case of T = 1,a=1
According to whether B is equal to a special award
And then the rest is going to look at the equation.
A0+a1t+a2t^2+...=a
A0+a1a+a2a^2+...=b
Then move the item to
A1+A2T + a3t^2+...= (a-a0)/t
A1+A2A + a3a^2+...= (b-a0)/A
You will find that the problem is recursive.
The value of A0 here is required
(a-a0)%t ==0
(B-A0)%a==0
which means a0%a = = b% A, a0% t = = a% t
And then it turns out that the amount of enumeration A0 is very small.
for a0%a = = B%a have a0= k * A + b%a0
A0 <= b && A0 <= a
Will find k=0 or 1, and must meet a0% t = = a% t
Then the next step is recursion. I got the answer.
#include < iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <algorithm> #include <map> #define MAXN 55555#define maxm 222222#define INF 1000000001using namespace Std;int Gao (Long long A, long long B, long long c, long long D) {if (b = = 0 && D = = 0) return 1; if (b = = 0 | | d = = 0) return 0; A long long ans = 0; For (long long i = 0; I <= 1; i++) {Long Long a0 = i * C + d% c; If (a0 > B | | a0 > D) break; if ((b-a0)% A = = 0) {ans + = Gao (A, (b-a0)/A, C, (D-A0)/C); }} return ans; int main () {long Long T, a, B; scanf ("%i64d%i64d%i64d", &t, &a, &b); if (t = = 1 && A = = 1) {if (b = = 1) {puts ("INF"); } else puts ("0"); } else printf ("%d\n", Gao (T, a, A, b)); return 0;}
Codeforces Round #281 (Div. 2)