首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >数学--数论--HDU 2674 沙雕题

数学--数论--HDU 2674 沙雕题

作者头像
风骨散人Chiam
发布2020-11-06 00:19:51
发布2020-11-06 00:19:51
5560
举报
文章被收录于专栏:CSDN旧文CSDN旧文

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

代码语言:javascript
复制
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]);
		    }
		}
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/12/20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档