Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

最无语的TLE!我是不知道原因!难道隐式转化很费时?唉~我怎么一到pku上做题都这种情况啊

Posted by jiangke at 2010-04-28 16:09:36 on Problem 2480
// poj 2480
// April 28,2010
#include<cstdio>
#include<cstring>

typedef long long LL;

int main(){
	int n,k,i;// 换成long long就Ac!!不然死活TLE!
	LL ans;
	while(scanf("%d",&n)==1){
		for(ans=n,i=2;i*i<=n;i++){
			if(n%i==0){
				k=0,ans/=i;
				while(n%i==0)
					n/=i,k++;
				ans*=i*(k+1)-k;
			}
		}
		if(n>1){
			ans/=n;
			ans*=2*n-1;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator