摘要:#include #include #include using namespace std; const int MAX = 25000; 1#include 2#include 3#include 4using namespace std; 5 6const int MAX = 25000; 7int num[MAX]; 8int mem[3][MA...
阅读全文
摘要:The 2007 ACM Asia Programming Contest - Nanjing Preliminary Damned words 这题有啥规律么?为什么人家293B就过了阿?而且内存还那么小。。。 All roads lead to Rome 啥意思?也没看懂,可是那么多人交了,好几百号人,没一个过的。。。 Mysterious nick 这题最郁闷,死在‘\’上了...
阅读全文
摘要:/**//*pku 3219 ****tip: n! = 2^k * k! * a k = n / 2 *** */ #include int cc(int n) { int sum=0; while(n>=2) { sum+= n/2; n/=2; } return sum; } int main() { int n, k; while(scanf("%d...
阅读全文
摘要:/*pku 2593 */ #include using namespace std; int a[100001]; __int64 s[100001],t[100001]; int main() { __int64 n,sum1,sum2,sum,p,q,i,j,k,b1,b2; while(cin>>n&&n!=0) { for(k=0;k...
阅读全文
摘要:#include using namespace std; int n,i,j,k; int a[101][101],s[101][101][101]; long b,sum,result; int main() { while(cin>>n&&n!=EOF) { for(i=1;i>a[i][j]; s[i][i][j]=a[i][j]; } for(i=1;...
阅读全文
摘要:结论是将N写成P进制数N0N1N2....Nm,答案就是(N+1) - (N0+1)*(N1+1)*...(Nm+1)。 证明是一个牛人写的: 组合数C(n,m)=n!/(m!(n-m)!)不被被素数P整除的充要条件是n!含有因子P的个数等于m!和(n-m)!含有因子P的个数之和。(//我就想到这一步...) 对任意正整数n,n!含有的素数因子P的个数为n/p+n/p^2+n/p^3........
阅读全文
摘要:#include using namespace std; int a[10]; int b[101]; int main() { int n,i,flag; while(cin>>n&&n!=0) { flag=0;for(i=0;i>a[i]; b[a[i]]++; } for(i=0;i<=100;i++) ...
阅读全文
摘要:#include using namespace std; int ok ; int d[6] ; void find ( int now , int x ) { if ( x d[x] ? d[x] : t ; if ( now - s * (x+1) != 0 ) for ( i = s ; i >= 0 ; i -- ) { find ( now - i * (x+1...
阅读全文
摘要://求n的阶乘转成10进制表示,末尾有多少个0的代码。 int f(int n) { int k = 5; int r = 0; while( n >= k) { r += n/k; k *= 5; } return r; } 然后这个还可以扩展为s进制的情况,这个等我扩出来了再写^_^ 算了,先写点初步的吧 就是...
阅读全文
摘要:#include using namespace std; struct par { string ma; string fa; }pp[100][1000]; string checkss(string a,string b,string c) { string re=""; int len=c.length(); fo...
阅读全文
摘要:#include using namespace std; int a[64],b[64]; __int64 poww(int x,int y) { __int64 t=1; for(int j=0;jnu)) break; return i; } int cc(__int64 d,__int64 e) {int s,t;...
阅读全文
摘要:其实就是求m和n的最大公约数,不过要大数,,可以用Euclid || stein写 #include #include char a[101],b[101]; int divide(int l,int ll); int big(int l,int ll,char a[],char b[]); void mod(int l,int ll); char x[101]; int ma...
阅读全文
摘要:#include #include #include using namespace std; const int maxn=210000; char s[maxn]; int len,k; int sa[maxn],rank[maxn],h[maxn],height[maxn]; int num[maxn]; inline bool leq(int a1, int a2, int b1, int...
阅读全文
摘要:nice~nice~~nice~~~nice~~~~nice~~~~~不爽... 今天比赛的进程大致就是这样的,前面5题很顺利的就过了,并且一直排在前三... 可是,到了D题,由于题目叙述相当有问题...实例和叙述严重不符,结果无奈,在那边猜题目的意思.然后实在没办法,只能把所有可能的情况都试着提交了一下,但是still wa,提交了3次,很快,剩下的3个小时就unnice地过了,k饭... 回来...
阅读全文
摘要:#include #include #include #include using namespace std; #define LimitN 100000 #define TC 100000 typedef struct node *point; struct node { point pl,sl; point chd,bro; ...
阅读全文
摘要:原来abs()只能返回int型的,int64和long long需要重写的
阅读全文
摘要:/**************************** *应用:找出字符串中重复出现的最长字符窜 *方法:使用后缀数组 *****************************/ # include # include # include # define NUM 1000 int cmp(const void *a,const void *b) { return(strcmp(*(cha...
阅读全文
摘要:CSuffixTree类有CreatTree,Show,Search,PrintNode四个方法,主要讨论CreatTree及Search方法. CreatTree:通过两层循环查找目标字符串的每一个前缀的所有后缀, 通过调用Search方法将结果分为四种。通过switch分别处理四种情况。 Search:搜索函数,通过遍历搜索参数传入的字符串。 将搜索结果通过point指针及其指向的节点的bre...
阅读全文
摘要:Welcome everyone especially ft2ers ^_^ and 。。。
阅读全文