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 makelove at 2008-11-22 02:20:20 on Problem 2917
#include<iostream>
using namespace std;
int n;
int solve(int N)
{
    int i,ans=1,t;
    for(i=2;i*i<=N;i++)
    {
        t=0;
        while(!(N%i))
        {
            t++;
            N/=i;
        }
        ans*=2*t+1;
    }
    if(ans==1||N!=1)ans*=3;
    return ans;
}
int main()
{
	int t,num=1,sum;
	cin>>t;
	while(t--){
	cin>>n;	
	sum=solve(n);
	if(n==1)sum=1;
	cout<<"Scenario #"<<num++<<":"<<endl;
	cout<<(sum+1)/2<<"\n"<<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