uva 1384(卢卡斯)

大神告诉我,这就是个板子,求杨辉三角第n+1层能被p整除的个数,记住就行,看了网上的证明过程,反正......我是看不懂

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int p,n;
const int mod=10000;
int main()
{   int kase=0;
     while(~scanf("%d%d",&p,&n)&&(p+n))
     {    kase++;
          int ans=1;
            while(n)
            {
               ans=ans*(n%p+1)%mod;
                n=n/p;
            }
           printf("Case %d: %04d\n",kase,ans);
     }
    return 0;
}

 

posted on 2017-08-28 09:59  发牌员  阅读(167)  评论(0)    收藏  举报

导航