(step7.2.4)hdu 2674(N!Again——简单数论)
2024-10-12 11:14:04
题目大意:输入一个整数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);
}
}
}
最新文章
- 安装Nginx服务
- 关于entityframework 自动生成实体类中加验证的属性重新生成后属性被覆盖解决办法
- (转)Image Segmentation with Tensorflow using CNNs and Conditional Random Fields
- HDU 4533 威威猫系列故事——晒被子
- VS2012给同一个解决方案添加多个项目
- DW(二):SqlServer PDW
- 关于SQL查询效率,100w数据,查询只要1秒
- TabControl控件的美化
- ORA-32001: write to SPFILE requested but no SPFILE specified at startup
- DKNightVersion的基本使用(夜间模式)
- 【转】FAE及其发展前景
- java 第三周作业
- ubuntu16.04下安装sublime_text
- 旧题新做:从idy的视角看数据结构
- Python开发【Django】:基础
- 【hive】cube和rollup函数
- 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;
- LevelDB Cache机制
- 我弄的一些TASKER配置
- 【spring cloud】子模块module -->;导入一个新的spring boot项目作为spring cloud的一个子模块微服务,怎么做/或者 每次导入一个新的spring boot项目,IDEA不识别子module,启动类无法启动/右下角没有蓝色图标