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)!

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

24

120

import java.util.Scanner;

public class Main {
static int ppp[]=new int [3000];
static void init() {
ppp[0]=ppp[1]=1;
for(int i=1;i<=2009;i++)
ppp[i]=(ppp[i-1]*i)%2009;
}
public static void main(String[] args) { init();
int l;
Scanner in = new Scanner(System.in);
while(in.hasNext()){
l=in.nextInt();
if(l>=2009)
System.out.println(0);
else
System.out.println( ppp[l]);
}
}
}

数学--数论--HDU 2674 沙雕题的更多相关文章

  1. 数学--数论--HDU - 6395 Let us define a sequence as below 分段矩阵快速幂

    Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only ...

  2. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  3. 数学--数论--hdu 5878 I Count Two Three(二分)

    I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...

  4. 数学--数论--HDU - 6124 Euler theorem (打表找规律)

    HazelFan is given two positive integers a,b, and he wants to calculate amodb. But now he forgets the ...

  5. 数学--数论--HDU 6063 RXD and math (跟莫比乌斯没有半毛钱关系的打表)

    RXD is a good mathematician. One day he wants to calculate: output the answer module 109+7. p1,p2,p3 ...

  6. 数学--数论--Hdu 5793 A Boring Question (打表+逆元)

    There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj! ...

  7. 数学--数论--HDU 2197 本原串 (推规律)

    由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串? 答案mod2008. 例如,100100不是本原串,因为他是由两个 ...

  8. 数学--数论--HDU 2802 F(N) 公式推导或矩阵快速幂

    Giving the N, can you tell me the answer of F(N)? Input Each test case contains a single integer N(1 ...

  9. 数学--数论--HDU 12151七夕节 Plus (因子和线性筛)

    Problem Description 七夕节那天,月老来到数字王国,他在城门上贴了一张告示,并且和数字王国的人们说:"你们想知道你们的另一半是谁吗?那就按照告示上的方法去找吧!" ...

随机推荐

  1. YII基础二

    YII多表关联查询 ->select("{{%relation_detail}}.name") ->from("{{%user}}") ->l ...

  2. Idea离线安装plugins插件 如Lombok

    由于公司不允许使用外网,之前用的idea 15 安装了一次.但是idea15的提示不够友好,今天升级idea2017.3.2,同样又需要安装,那就写个教程吧. 网上其他的安装教程不通用,也是针对不同i ...

  3. compareAndSet() 注意点

    compareAndSet()与weakCompareAndSet()是有条件的修改程序的方法,这两个方法都要取用两个参数:在方法启动时预期数据所具有的的值,以及要把数据所设定成的值.它们都只会在变量 ...

  4. web网页html基础

    列表标签 ul:定义一个列表 li:定义列表中的条目 图片标签 Img:用来向网页中插入一张图片 Src:指定图片所在的路径 Width:指定图片宽度 (% px) Height:指定图片高度 (% ...

  5. Python分析数据难吗?某科技大学教授说,很难但有方法就简单

    用python分析数据难吗?某科技大学的教授这样说,很难,但要讲方法,主要是因为并不是掌握了基础,就能用python来做数据分析的. 所谓python的基础,也就是刚入门的python学习者,学习的基 ...

  6. 第十一节:configParse模块

    作用:配置文件解析模块,用来增删改查配置文件内容,不区分大小写 配置文件案例: tets.ini [模块] key=value import configparser config = configp ...

  7. 好玩的GeoGebra

    目前,在网站上看到好多大牛写的信号方面的笔记,有很多好玩的gif好玩又让人能明白其中的原理,工欲善其事必先利其器,在写我的博客方面先来学一个好玩的数学软件吧. GeoGebra官网如图 它是一个小巧的 ...

  8. Crossing River POJ过河问题

    A group of N people wishes to go across a river with only one boat, which can at most carry two pers ...

  9. 网站假死 重启NGINX无效 必须重启PHP 原因分析

    一.错误提示说明: Nginx 502 Bad Gateway:请求的PHP-CGI已经执行,但是由于某种原因(一般是读取资源的问题)没有执行完毕而导致PHP-CGI进程终止. Nginx 504 G ...

  10. idea ------- 源码调试运行

    1.创建一个 想学 的 ,使用单步调试进行一步步学习 调整系统资源 单步调试 (F7) ,进入不了源码,调整idea 让我们可以进入底层学习 想要在源码里面添加注释,要将引用的源文件指向,我们刚才复制 ...