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????????

Posted by ecjtubaowp at 2006-11-18 19:59:42 on Problem 3090
#include<stdio.h>
int main()
{
 int i,j,k,m,n,sum,save,m0;
 scanf("%d",&n);
 for(k=1;k<=n;k++)
 {
 sum=0;
 scanf("%d",&m);
 if(m==1){printf("%d %d %d\n",k,1,3);continue;}
 for(i=2;i<=m;i++)
 {
  m0=i;
  save=m0;
  if(m0%2==0)save/=2;
  while(m0%2==0)m0/=2;
  for(j=3;m0!=1;j+=2)
  {
   if(m0%j==0)save=save/j*(j-1);
   while(m0%j==0)m0/=j;
  }
  sum+=save;
 }
 
  
  printf("%d %d %d\n",k,m,2*sum+3);
  
 }//for
 
}//main

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