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

why wa??

Posted by wanglinggui at 2007-11-07 16:01:58 on Problem 3421
#include <iostream>
using namespace std;

const int MAX=(1<<20)+10;

int c[MAX], vis[MAX];
__int64 a[MAX], jie[21];
void set()
{
	int i, j, t, tag, k;
	
	jie[0]=1;
	for(i=1; i<21; ++i)
		jie[i]=i*jie[i-1];
	
	fill(a, a+MAX, 1);
	for(i=2; i<2000; ++i)
	{
		if(!vis[i])
		{
			for(j=i; j<MAX; j+=i)
			{
				vis[j]=1;
				t=j;
				tag=0;
				while(t%i==0)
				{
					t/=i;
					tag++;
				}
				a[j]*=jie[tag];
				c[j]+=tag;
			}
		}
	}
	for(i=2; i<MAX; ++i)
	{
		if(!vis[i])
		{
			vis[i]=1;
			c[i]=1;
		}
		else vis[i]=jie[c[i]]/a[i];
	}
}

int main()
{
	set();
	int i;
	while(scanf("%d", &i)==1)
	{
		printf("%d %d\n", c[i], vis[i]);
	}
	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