题目学习——HDUOJ-2674
来源:互联网 发布:剪辑音乐的软件 编辑:程序博客网 时间:2024/06/05 10:58
哇,超激动呢,第一次自己所谓的打表成功~!!
N!Again
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem Description
WhereIsHeroFrom: Zty, what are you doing ?
Zty: I want to calculate N!......
WhereIsHeroFrom: So easy! How big N is ?
Zty: 1 <=N <=1000000000000000000000000000000000000000000000…
WhereIsHeroFrom: Oh! You must be crazy! Are you Fa Shao?
Zty: No. I haven's finished my saying. I just said I want to calculate N! mod 2009
Hint : 0! = 1, N! = N*(N-1)!
Zty: I want to calculate N!......
WhereIsHeroFrom: So easy! How big N is ?
Zty: 1 <=N <=1000000000000000000000000000000000000000000000…
WhereIsHeroFrom: Oh! You must be crazy! Are you Fa Shao?
Zty: No. I haven's finished my saying. I just said I want to calculate N! mod 2009
Hint : 0! = 1, N! = N*(N-1)!
Input
Each line will contain one integer N(0 <= N<=10^9). Process to end of file.
Output
For each case, output N! mod 2009
Sample Input
4 5
Sample Output
24120
Author
WhereIsHeroFrom
#include <iostream>#include <cstdio>/*int main(){ int NI[5000]; NI[0]=1; freopen("output.txt","w",stdout); for(int i=1;i<5000;++i) NI[i]=(NI[i-1]*i)%2009; for(int i=0;i<5000;++i){ printf("%d,",NI[i]); if(!(i%10))printf("\n"); } return 0;}*/int main(){ int NI[41]={1, 1,2,6,24,120,720,1022,140,1260,546, 1988,1757,742,343,1127,1960,1176,1078,392,1813, 1911,1862,637,1225,490,686,441,294,490,637, 1666,1078,1421,98,1421,931,294,1127,1764,245}; int N; while(scanf("%d",&N)!=EOF){ if(N>40)printf("0\n"); else printf("%d\n",NI[N]); } return 0;}
阅读全文
0 0
- 题目学习——HDUOJ-2674
- 题目学习——hduoj-2136
- 题目学习——HDUOJ-1492
- 题目学习——HDUOJ-2669
- 课堂学习——HDUOJ-1215
- 课堂学习——HDUOJ-1452
- hduoj 题目分类
- HDUOJ题目分类
- hduoj题目详细分类
- hduoj题目分类
- HDUoj PBD 题目1703
- HDUOJ 无题 题目1871
- hduoj 排序 题目1106
- hduoj 4196 ——Remoteland
- BigNums——HDUOJ 1002
- BigNums——HDUOJ 1042
- BigNums——HDUOJ 1047
- BigNums——HDUOJ 1063
- Handler详解
- 面试记录,加油!(停更)
- 剑指offer 之 包含min函数的栈
- HDU 1800 Flying to the Mars
- 关于gis坐标中的ZM
- 题目学习——HDUOJ-2674
- eclipse oxygen4.7.0 bug: jsp html 标签Option 嵌入jsp标签如<c:if>报错
- 双向链表的简单实现
- dubbo常见错误
- html css与html交互的4种方式
- 单词搜索迷宫
- 工作一年总结之一项目环境搭建
- 大家好,我是小玩很高兴认识大家
- 找新朋友||HDU1286