http://acm.hdu.edu.cn/showproblem.php?pid=2674 (很神奇)
2010-08-09 19:38
399 查看
]/* * 一开始 2009 后面的全部为0 前面的用BigInteger 暴力 TLE * 后来试了很多收据从41开始后面的数据全部为0 前面的乘下就OK了 */ import java.util.*; import java.io.*; import java.math.*; public class Main2674 { //static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); //static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static Scanner cin = new Scanner(new BufferedInputStream(System.in)); public static void main(String[] args){ while(cin.hasNext()){ BigInteger a = cin.nextBigInteger(); if(a.compareTo(BigInteger.valueOf(41)) >= 0){ //out.println(0); System.out.println("0");; continue; } BigInteger ans = BigInteger.ONE; for(int i = 2; i <= a.intValue(); i++){ ans = ans.multiply(BigInteger.valueOf(i)); } /* long ans = 1; for(int i = 2; i <= a.intValue(); i++){ ans = (ans * i) % 2009; } */ //System.out.println(ans); //out.println(ans.remainder(BigInteger.valueOf(2009))); System.out.println(ans.remainder(BigInteger.valueOf(2009))); } //out.flush(); } }
相关文章推荐
- http://acm.hdu.edu.cn/showproblem.php?pid=1905 素数判断 + 二分
- http://acm.hdu.edu.cn/showproblem.php?pid=1166
- http://acm.hdu.edu.cn/showproblem.php?pid=2689
- 最大报销额 http://acm.hdu.edu.cn/showproblem.php?pid=1864
- http://acm.hdu.edu.cn/showproblem.php?pid=1698 成段更新,总区间求和
- http://acm.hdu.edu.cn/showproblem.php?pid=2604
- http://acm.hdu.edu.cn/showproblem.php?pid=1010
- http://acm.hdu.edu.cn/showproblem.php?pid=1255 扫描线 + 线段树 +离散化
- FatMouse' Trade http://acm.hdu.edu.cn/showproblem.php?pid=1009
- N! http://acm.hdu.edu.cn/showproblem.php?pid=1042
- 亲和串 http://acm.hdu.edu.cn/showproblem.php?pid=2203
- http://acm.hdu.edu.cn/showproblem.php?pid=3501 欧拉函数
- http://acm.hdu.edu.cn/showproblem.php?pid=1709
- http://acm.hdu.edu.cn/showproblem.php?pid=1102 -- kruskal算法和prim算法
- http://acm.hdu.edu.cn/showproblem.php?pid=1055&&Color a Tree
- Big Number(http://acm.hdu.edu.cn/showproblem.php?pid=1018)
- Substrings &&http://acm.hdu.edu.cn/showproblem.php?pid=1238
- Text Reverse&&http://acm.hdu.edu.cn/showproblem.php?pid=1062
- Robberies&&http://acm.hdu.edu.cn/showproblem.php?pid=2955
- http://acm.hdu.edu.cn/showproblem.php?pid=1525