然后接下来就是递归了。就得出答案了
 
 
#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的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did106465