题目1037:Powerful Calculator
参考代码:偷懒直接用BigInteger
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
public class Main {
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int num = sc.nextInt();
int total=0;
for(int i=1;;i++)
{
int sum=1;
for(int j=1;j<=i;j++){
sum *=j;
}
total +=sum;
if(total == num) {
System.out.println("YES");
break;
}
if(total > num) {
System.out.println("NO");
break;
}
}
}
}
}