标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4781 Accepted Submission(s): 2527
4 5
24 120
看到n的范围 脑子里就知道是规律。。。
其实把结果输出一下就看到了。如果某个值正好整除2009 那么 后面的都是0了
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sca=new Scanner(System.in); while(sca.hasNext()){ int x=sca.nextInt(); if(x>41){ System.out.println(0); continue; } BigInteger res=BigInteger.ONE; for(int i=2;i<=x;i++){ res=res.multiply(BigInteger.valueOf(i)); res=res.mod(BigInteger.valueOf(2009)); } System.out.println(res); } } }
标签:
原文地址:http://blog.csdn.net/su20145104009/article/details/52153883