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

你的代码好挤,而且有废话.帮你改了改

Posted by fbixiaozc135 at 2007-08-24 00:08:38 on Problem 2603
In Reply To:Re:改后代码... Posted by:mayp at 2007-03-16 14:01:20
#include<iostream>
using namespace std;

const MAX = 10000;
int prime_set[MAX];
int main()
{
    int a,x,i;

    fill_n(prime_set, MAX, 0);

    for(i = 0; i < 10; ++i)
    {
       cin >>x; 
	   a = x;
       if (a == 1)
		   continue;
       else
         for (int j = 2; j <= x; ++j)
		 {
            
            while ( (a % j) == 0 )//相当于是筛选法求素数
            {
				a /= j;
				++prime_set[j];
			}
            if (a == 1) 
				 break;
		 }
    }

    int last = 1;
    for (i = 0; i < MAX; ++i)
    {
		if (prime_set[i]) 
			last *= (prime_set[i] + 1);
		    last %= 10;
	}

    cout << last << endl;

    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