Aug 312011
 

단순한 실수 때문에 몇번 실패 했다.. 출력할 때 개행에 주의해야할 것 같다.

import java.math.BigInteger;

import java.util.Scanner;

public class Main {

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

int testcase;

testcase = scan.nextInt();

while (testcase– > 0)

{

BigInteger n = scan.nextBigInteger();

int count = 0;

boolean sign = true;

while (sign)

{

String n1 = n.toString();

StringBuffer sb1 = new StringBuffer(n1);

String n2 = sb1.reverse().toString();

if (n1.equals(n2))

{

sign = false;

}

else

{

BigInteger p1 = new BigInteger(n1);

BigInteger p2 = new BigInteger(n2);

n = p1.add(p2);

count++;

}

}

System.out.println(count + ” ” + n);

}

}

}


 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.