摘要://题意是对于给定的x,求满足n! #include #include#include #include #include #include #include using namespace std;// #define LL __int64#define LL long longconst double pi=acos(-1.0);const double inx_2=log(2.0); // log -> inx log10int f[30];int main(){ f[0]=1; int i; for(i=1;i<30;i++) f[i]=f[i-1]*2; int ...
        
阅读全文
 
    
        
        
摘要:// 用h[n]表示n节火车的出站方法总数// 那么分别考虑每一辆车最后出站// 比如第一辆最后出站 则 有 h[0]*h[n-1]种出站方法// 第二辆最后出站 则 有 h[1]*h[n-2]种出站方法// ... // 第i辆最后出站 则 有 h[i-1]*h[n-i]种出站方法// 卡特兰数 // 递推公式 h[n]=h[n-1]*(4*n-2)/(n+1);#include #include #include#include #include #include #include #include using namespace std;#define LL long lon...
        
阅读全文
 
    
        
        
摘要:// 将n个相同的球放进m个盒子 盒子不为空的方法总数// dp[i][j] 表示i个盒子 j个球的方法总数// 递推关系 dp[i][j]=dp[i-1][j-1]+d[i][j-i]// a. i-1个盒子放j-1个球 第j个球放进第i个盒子中// b. i个盒子放了j-i个球 再放进i个球 每个盒子放一个// 注意 ans=ans+dp[i][n-k*i+i] 这里的 n-k*i+i // 加 i 的目的是为了 n-k*i+i>=i 这样就得到盒子不为空计数 #include #include #include #include #include #include #include
        
阅读全文
 
    
        
        
摘要:// 列出了 n=5 时 5,4,3,2,1 出现的次数为 1 2 5 12 28f[n+1]=3*f[n]-f[n-1]-f[n-2]-..f[1]f[n]=3*f[n-1]-f[n-2]-..f[1]==> f[n+1]=4*f[n]-4*f[n-1]矩阵快速运算就可以得出答案了// 开始提交时老错 结果是被 k>n 这种数据给坑了、、郁闷#include #include #include #include #include #include using namespace std;void deal(__int64 a[2][2],__int64 n,int m){ __i
        
阅读全文
 
    
        
        
摘要:BalanceTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 8754Accepted: 5320DescriptionGigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and each arm's length is 15. S
        
阅读全文
 
    
        
        
摘要:A Short problemTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 779Accepted Submission(s): 296Problem Description According to a research, VIM users tend to have shorter fingers, compared with Emacs users. Hence they prefer problems short, too. He..
        
阅读全文
 
    
        
        
摘要:汉诺塔IXTime Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 404Accepted Submission(s): 235Problem Description1,2,...,n表示n个盘子.数字大盘子就大.n个盘子放在第1根柱子上.大盘不能放在小盘上. 在第1根柱子上的盘子是a[1],a[2],...,a[n]. a[1]=n,a[2]=n-1,...,a[n]=1.即a[1]是最下 面的盘子.把n个盘子移动到第3根柱子.每次只能移动1个盘子,且
        
阅读全文