还没理解但有结论的数论题

1.求 a , b 不能组合出的最大的数,以及个数

http://acm.hdu.edu.cn/showproblem.php?pid=1792
结论:
①:不能组合出的最大数: a b a b
②:个数: ( a 1 ) ( b 1 ) 2
没怎么看懂的证明:
http://blog.sina.com.cn/s/blog_79b832820100riqp.html

2.斐波那契数列平方和

结论:

f 2 ( 1 ) + f 2 ( 2 ) + f 2 ( 3 ) + f 2 ( 4 ) + f 2 ( 5 ) + . . . + f 2 ( n ) = f ( n ) f ( n + 1 )

3.n的阶乘在m进制下末尾0的个数

没有懂原理。。。

#include"bits/stdc++.h"
#define out(x) cout<<#x<<"="<<x
using namespace std;
typedef long long LL;
LL solve(LL n,LL m)
{
    LL res=0;
    while(n)
    {
        res+=n/m;
        n/=m;
    }
    return res;
}
int main()
{
    LL N,M;
    while(cin>>N>>M)
    {
        LL ans=1e18;
        for(LL i=2;i*i<=M;i++)
        {
            if(M%i==0)
            {
                LL cnt=0;
                while(M%i==0)M/=i,cnt++;
                ans=min(ans,solve(N,i)/cnt);
            }
        }
        cout<<ans<<endl;
    }
} 

4.格点多边形面积(皮克定理)

n 1 为内部格点的数目
n 2 为边上格点的数目

S = n 1 + n 2 2 1

猜你喜欢

转载自blog.csdn.net/swustlpf/article/details/81135748