N!again
来源:互联网 发布:快盘关闭数据如何找回 编辑:程序博客网 时间:2024/06/06 11:04
F - N!Again
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
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
找规律,2009=41*7*7
比41大的取模为0
#include <iostream>#include <cstdio>int app(int t){int sum=1;while(t) {sum=sum%2009;sum=sum%2009*t; sum=sum%2009;t--; }return sum; } int main(){int n;while(~scanf("%d",&n)){ if(n<41) printf("%d\n",app(n));elseprintf("0\n");}return 0; }
阅读全文
0 0
- N!Again
- N!Again
- N!again
- HDU 2674 N! Again
- HDU 2674 N! Again
- 【ACM Steps】N!Again
- hdu 2674 N!Again
- hdu2674 N!Again
- hdu2674 N!Again
- HDU 2674 N!Again
- HDU--2674 N!Again
- hdu-2674-N!Again
- HDU_2674 N!Again
- HDU2674 N!Again 【数学】
- hdu2674 N!Again
- N!Again(数论)
- hd2674 N!Again
- hdoj 1003 N!Again
- 虚拟主机 VPS 云服务器的区别
- 关于StarUML的基础概念
- WLAN无线局域网组成
- Nginx的命令行控制
- Putty与SecureCRT公钥密钥互转
- N!again
- ESP8266字节序与比特序的验证
- 什么是spurious wakeups(虚假唤醒)
- 关于ABI OABI EABI
- armel和armhf区别
- Service初步识别(三)
- 使用spawn和expect实现自动交互
- macOS文本编辑快捷键
- eclipse关联svn