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

Re:国庆快乐,转发代码 Happy一下

Posted by 0_2 at 2018-10-06 14:53:19 on Problem 1995
In Reply To:国庆快乐,附个代码 Happy一下 Posted by:ACAccepted at 2018-10-06 14:49:58
> #include <cstdio>
> using namespace std;
> int cas,m,n;
> long long a,b,ans;
> 
> long long js(long long a,long long b)
> {
> 	if(b==0)return 1;
> 	if(b==1)return a;
> 	long long res=js(a,b/2);
> 	if(b%2==0)return res*res%m;
> 	else return res*res*a%m;
> }
> 
> int main()
> {
> 	scanf("%d",&cas);
> 	while(cas--)
> 	{
> 		scanf("%d%d",&m,&n);
> 		ans=0;
> 		while(n--)
> 		{
> 			scanf("%I64d%I64d",&a,&b);
> 			a=a%m;
> 			ans=(ans+js(a,b))%m;
> 		}
> 		printf("%I64d\n",ans);
> 	}
> 	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