Files
Story-With-Thanh/J07003 - TÁCH ĐÔI VÀ TÍNH TỔNG.java
T
2022-12-15 23:51:04 +07:00

25 lines
754 B
Java

import java.util.Scanner;
import java.io.File;
import java.math.BigInteger;
import java.io.FileNotFoundException;
public class Main{
public static void main(String args[]){
File x = new File("DATA.in");
try{
Scanner sc = new Scanner(x);
BigInteger s = sc.nextBigInteger();
while(s.toString().length() > 1){
int length = s.toString().length();
BigInteger a = new BigInteger(s.toString().substring(0,length/2));
BigInteger b = new BigInteger(s.toString().substring(length/2,length));
s = a.add(b);
System.out.println(s);
}
sc.close();
}catch(FileNotFoundException e){
}
}
}