摘要: Humble NumbersTime Limit: 2 Seconds Memory Limit: 65536 KBA number whose only prime factors are 2,3,5 or 7 is called a humblenumber. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.Write a program to find and print the nth el. 阅读全文
posted @ 2012-04-10 23:04 mtry 阅读(291) 评论(0) 推荐(0)
摘要: LottoTime Limit: 2 Seconds Memory Limit: 65536 KBIn a Lotto I have ever played, one has to select 6 numbers from the set {1,2,...,49}. A popular strategy to play Lotto - although it doesn't increase your chance of winning - is to select a subset S containing k (k>6) of these 49 numbers, and t 阅读全文
posted @ 2012-04-10 21:10 mtry 阅读(667) 评论(0) 推荐(0)
摘要: 求f(n)%p描述:f(0)=1;f(1)=1;f(2)=2;f(n)=f(n-1)+f(n-2);输入:两个整数n和p;输出:f(n)%p;方法一:矩阵快速模幂struct SS{int S[2][2];}A;A.S[0][0]=0;A.S[0][1]=1;A.S[1][0]=1;A.S[1][1]=1;A=A^n;f(n)=A.S[1][1];1、C++递归实现(这个方法是我常用的):View Code 1 #include<iostream> 2 using namespace std; 3 4 struct SS{int S[2][2];}; 5 int n=2,p; 6 阅读全文
posted @ 2012-04-10 11:25 mtry 阅读(1191) 评论(0) 推荐(0)