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 13408100238 at 2014-08-01 19:22:54 on Problem 3090
/*
	Name: Visible Lattice Piints pku 3090
	Copyright: Shangli Cloud
	Author: Shangli Cloud
	Date: 01/08/14 16:09
	Description: 
*/
#include"iostream"
#include"cstdio"
#include"cstring"
#include"algorithm"
using namespace std;
const int ms=1e3+10;
long long phi[ms];
int p;
void solve(int n)
{
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=phi[i];
	cout<<p++<<" "<<n<<" "<<ans*2+1<<endl;
	return ;
}
int main()
{
	int i,j,n,t;
	for(i=1;i<ms;i++)
		if(i&1)
			phi[i]=i;
		else
			phi[i]=i/2;
	for(i=3;i<ms;i+=2)
		if(phi[i]==i)
			for(j=i;j<ms;j+=i)
				phi[j]=phi[j]/i*(i-1);
	cin>>t;
	p=1;
	while(t--)
	{
		cin>>n;
		solve(n);
	}
	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