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

哪里错了 一直WA 谢谢大家了

Posted by lyq at 2009-07-14 22:58:32 on Problem 3734
#include<iostream>
using namespace std;
int Mod = 10007;
int GetMod(long int n,int value) 
{
	int result=1;
	if(n==1) return (result*value)%Mod;
	while(n>1)
	{
		if(n%2==1){
			result = (result*value)%Mod;
			n -= 1;
		} else {
			result = (result*value*value)%Mod;
			n /= 2;
		}
	}
	return result;
}
int main()
{
	
	int cases,rel;
	long int n;
	scanf("%d",&cases);
	while(cases--)
	{
		scanf("%ld",&n);
		rel = (GetMod(n-1,2)+GetMod(n-1,4))%Mod;
		printf("%d\n",rel);
	}
	
	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