题目大意:输入一个整数n,输出N! mod 2009 的结果。

解题思路:

1)任意数  n = ( n / 2009) * 2009 + n % 2009

2)40!  mod 2009  等于 245

3)41!  mod 2009 等于 0

4) 对于小于 2009 的数来说   n == n % 2009

代码如下:

/*
* 2674_1.cpp
*
* Created on: 2013年9月1日
* Author: Administrator
*/ #include <stdio.h> int main(){
int n;
while(scanf("%d",&n)!=EOF){
if( n >= 41){
printf("0\n");
}else{ int temp = 1;
while(n >= 1){
temp *= n;
temp %= 2009;
n--;
} printf("%d\n",temp);
}
}
}

最新文章

  1. 安装Nginx服务
  2. 关于entityframework 自动生成实体类中加验证的属性重新生成后属性被覆盖解决办法
  3. (转)Image Segmentation with Tensorflow using CNNs and Conditional Random Fields
  4. HDU 4533 威威猫系列故事——晒被子
  5. VS2012给同一个解决方案添加多个项目
  6. DW(二):SqlServer PDW
  7. 关于SQL查询效率,100w数据,查询只要1秒
  8. TabControl控件的美化
  9. ORA-32001: write to SPFILE requested but no SPFILE specified at startup
  10. DKNightVersion的基本使用(夜间模式)
  11. 【转】FAE及其发展前景
  12. java 第三周作业
  13. ubuntu16.04下安装sublime_text
  14. 旧题新做:从idy的视角看数据结构
  15. Python开发【Django】:基础
  16. 【hive】cube和rollup函数
  17. cannot nest &#39;/dubboService/src/main/resources&#39; inside &#39;/dubboService/src/main&#39; .To enable the nesting exclude &#39;/resources&#39; from &#39;/dubboService/src/main&#39;
  18. LevelDB Cache机制
  19. 我弄的一些TASKER配置
  20. 【spring cloud】子模块module --&gt;导入一个新的spring boot项目作为spring cloud的一个子模块微服务,怎么做/或者 每次导入一个新的spring boot项目,IDEA不识别子module,启动类无法启动/右下角没有蓝色图标

热门文章

  1. QT窗口拖拽功能简单应用(处理dragEnterEvent和dropEvent事件,不同的事件有不同的信息,比如mimeData)
  2. Sightseeing Cows(最优比率环)
  3. rman 使用catalog备份的演示
  4. Js用正则表达式验证字符串
  5. 使用超链接跳转页面(GridView)
  6. Android中图片处理相关问题
  7. 解决centos7安装wmwaretools找不到kernel header
  8. C++学习之虚继承
  9. gets函数完美替代
  10. js中的typeof