好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

CodeforcesRound#281(Div.2)_html/css_WEB-ITnose

这场题也不难。

a0 会发现k=0或者1,而且必须满足a0 % t == a % t


然后接下来就是递归了。就得出答案了



#include  #include  #include  #include  #include  #include #include  #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;    long long ans = 0;    for(long long i = 0; i   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;} 

查看更多关于CodeforcesRound#281(Div.2)_html/css_WEB-ITnose的详细内容...

  阅读:32次