View Code of Problem 1080

/* Author : yan
 * Question : POJ 1995 Raising Modulo Numbers
 * Data && Time : Wednesday, January 19 2011 12:40 PM
 * Compiler : gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
*/
#include<stdio.h>

int modexp(long long a,long long b,long long n)
{
    int ret=1;
    long long tmp=a;
    while(b)
    {
       //基数存在
       if(b&0x1) ret=ret*tmp%n;
       tmp=tmp*tmp%n;
       b>>=1;
    }
    return ret;
}

int main()
{
	//freopen("input","r",stdin);
	int z;
	int m;
	int ans;
	int h;
	int a,b;
	scanf("%d",&z);
	while(z--)
	{
		ans=0;
		scanf("%d",&m);
		scanf("%d",&h);
		while(h--)
		{
			scanf("%d %d",&a,&b);
			ans+=modexp(a,b,m);
			ans%=m;
		}
		printf("%d/n",ans);
	}
	return 0;
}
</textarea> 
/*
F:\temp\16139770.54787\Main.cc:47: error: expected unqualified-id before '<' token
*/

Double click to view unformatted code.


Back to problem 1080