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

求勒让德符号。。。a^(P-1)/2 %P. JAVA无耻的水过

Posted by Ly86 at 2010-05-10 22:23:04 on Problem 1808
import java.math.*;
import java.io.*;
import java.util.*;
class Main{
	
	
	public static void main(String args[]){
		Scanner cin =  new Scanner(System.in);
		int k =1;
		BigInteger a,b;
		int t= cin.nextInt();
		BigInteger two = new BigInteger("2");
		while(t--!=0){
			a = cin.nextBigInteger();
			b = cin.nextBigInteger();
			System.out.println("Scenario #"+k+":");
			k++;
	if(a.modPow(b.add(BigInteger.ONE.negate()).divide(two), b).compareTo(BigInteger.ONE)==0)
		    	System.out.println("1");
		    else
		    	System.out.println("-1");
	System.out.println();
		}
	}
	
}

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