Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么这个会RE?import java.math.BigInteger; import java.security.SecureRandom; import java.util.Scanner; public class Main { private final static BigInteger ZERO = new BigInteger("0"); private final static BigInteger ONE = new BigInteger("1"); private final static BigInteger TWO = new BigInteger("2"); private final static SecureRandom random = new SecureRandom(); static BigInteger fac[] = new BigInteger[64]; static BigInteger T=new BigInteger("0"); static BigInteger D=new BigInteger("0"); static BigInteger C=new BigInteger("0"); static BigInteger E=new BigInteger("0"); static BigInteger N=new BigInteger("0"); static int f; public static BigInteger rho(BigInteger N) { BigInteger divisor; BigInteger c = new BigInteger(N.bitLength(), random); BigInteger x = new BigInteger(N.bitLength(), random); BigInteger xx = x; // check divisibility by 2 if (N.mod(TWO).compareTo(ZERO) == 0) return TWO; do { x = x.multiply(x).mod(N).add(c).mod(N); xx = xx.multiply(xx).mod(N).add(c).mod(N); xx = xx.multiply(xx).mod(N).add(c).mod(N); divisor = x.subtract(xx).gcd(N); } while((divisor.compareTo(ONE)) == 0); return divisor; } public static void factor(BigInteger N) { if (N.compareTo(ONE) == 0) return; if (N.isProbablePrime(60)) { fac[f++]=N; return; }; BigInteger divisor = rho(N); factor(divisor); factor(N.divide(divisor)); } public static void main(String[] args) { Scanner cin = new Scanner(System.in); while(true){ if(cin.hasNext()==false) break; C=cin.nextBigInteger(); E=cin.nextBigInteger(); N=cin.nextBigInteger(); f=0; factor(N); T=fac[0].subtract(ONE).multiply(fac[1].subtract(ONE)); D=E.modInverse(T); System.out.println(C.modPow(D, N)); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator