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 pb03005073 at 2007-03-19 16:25:57 on Problem 1995
郁闷
附代码:
#include <iostream>
#include <cmath>

using namespace std;

void main()
{
	int z,m,h;
	cin>>z;

	for(int i=0;i<z;i++)
	{
		int a,b;
		__int64 ans=1,sum=0;
		cin>>m>>h;
		
		for(int j=0;j<h;j++)
		{
			scanf("%d%d",&a,&b);
			ans=1;
			for(int k=0;k<b;k++)
				ans=ans*a%m;

			sum=(sum+ans)%m;
		}
		printf("%d",sum);
		cout<<endl;
	}
}

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