题目链接 :https://nanti.jisuanke.com/t/26217
Description:
There is a positive integer X, X's reversion count is Y. For example, X=123, Y=321; X=1234, Y=4321. Z=(X-Y)/9, Judge if Z is made up of only one number(0,1,2...9), like Z=11,Z=111,Z=222,don't consider '+'and '-'.
Input:
Input contains of several test cases. Each test case only contains of a number X, L is the length of X. ( 2 <= L < 100)
Output:
Output “YES”or “NO”.
样例输入
10 13
emmmm,贴这题代码只是想纪念下自己速成的java,以这题结束吧
宁夏网络赛自己打到的名额,被教练扔给其他队,23333....
理由:“你不是自己参加了清华校赛了吗?还出去干嘛....”
666,向教练低头....
import java.math.BigDecimal; import java.util.Scanner; import java.math.*; import java.text.*; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); BigInteger a; while(cin.hasNextBigInteger()) { a=cin.nextBigInteger(); String strA=a.toString(10); BigInteger b=BigInteger.valueOf(0); BigInteger tt; int tmp; BigInteger ten=BigInteger.TEN; for(int i=strA.length()-1;i>=0;i--) { tmp=strA.charAt(i)-'0'; tt=BigInteger.valueOf(tmp); b=b.multiply(ten).add(tt); } BigInteger ans; if(a.compareTo(b)<0) ans=b.subtract(a); else ans=a.subtract(b); ans=ans.divide(BigInteger.valueOf(9)); String strB=ans.toString(10); int flag=1; for(int i=1;i<strB.length()&&flag==1;i++) { if(strB.charAt(i-1)!=strB.charAt(i)) flag=0; } if(flag==1) System.out.println("YES"); else System.out.println("NO"); } } }