×

# Google Code jam kickStart Problem A : Huge Number

Can any one please tell it is giving wrong answer but it is working for sample test case My Solution

/*

###### ###### ##### ###### ######

# # # # # # # # # # # # # # # # # ## # # ## # # # # # # # # # # # # #

###### # # # # # # # # #

/ import java.util.; import java.lang.; import java.io.; import java.math.*; class hugenumber { public static void main(String args[] ) throws Exception { Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); PrintStream p = System.out; int t =scan.nextInt(); int i=1; while(t-->0){

        int a =scan.nextInt();
int n =scan.nextInt();
int d =scan.nextInt();
BigInteger fact = factorial(n);
BigInteger bi1 = new BigInteger(Integer.toString(a));
BigInteger bi2 = new BigInteger(Integer.toString(d));
BigInteger bi3 = bi1.modPow(fact, bi2);
p.println("Case #" + i + ": " +bi3);
i++;
}

}
static BigInteger factorial(int n){
BigInteger fact= BigInteger.ONE;
int factorialNo = 100;

for (int i = 2; i <= factorialNo; i++){
fact = fact.multiply(new BigInteger(String.valueOf(i)));
}
return fact;
}


}

2★drjaat
267111
accept rate: 6%

y were u looping till 100 in factorial method?

(22 Oct '17, 14:11)

that was silly how did i miss that Thanks @beginner_1111

(22 Oct '17, 14:44) 2★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×633
×40
×40

question asked: 22 Oct '17, 13:32

question was seen: 559 times

last updated: 22 Oct '17, 14:44