Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这个也能TLE吗????#include <iostream> using namespace std; const int MAX=(1<<20)+1; int a[MAX], c[MAX]; void set() { int i, j, t; c[1]=1; for(i=1; i<MAX; ++i) { t=a[i]+1; for(j=i+i; j<MAX; j+=i) { if(a[j]<t) { a[j]=t; c[j]=c[i]; } else if(a[j]==t) c[j]+=c[i]; } } } int main() { set(); int i; while(scanf("%d", &i)==1) { printf("%d %d\n", a[i], c[i]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator