|
|
back to boardTo Admins something wrong with the 1st test or tests Following prog give me ans for all n (1..100) but at first test it gave me TL import java.math.BigInteger; import java.util.Scanner; public class Timus1407 { public static void main(String[] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); String s = "2"; BigInteger two = new BigInteger("2"); for (int i = 2; i <= n; i++) { BigInteger bigInteger = two.pow(i); String tmp = "1" + s; if(new BigInteger(tmp).mod(bigInteger) == BigInteger.ZERO){ s = tmp; } else{ s = "2" + s; if(new BigInteger(s).mod(bigInteger) != BigInteger.ZERO){ for(;;){} } } } System.out.print(s); } } Re: To Admins Strange... On my computer it gives nothing except infinite running. You shouldn't compare BigInteger with "==". Use "compareTo" method. thanks stupid mistake Strange but it is not tl in my computer. Its working still. |
|
|