poj 1604 Just the Facts
- /**
- 大意: 求n! 结果 从左到右 第一个非零数
- 跟 1150 差不多。。
- **/
- #include <iostream>
- #include <cstdio>
- using namespace std;
- int s[][]={
- {,,,},{,,,},{,,,},{,,,}
- };
- int get2(int n){
- if(n==)
- return ;
- return n/+get2(n/);
- }
- int get5(int n){
- if(n==)
- return ;
- return n/+get5(n/);
- }
- int get(int n,int x){
- if(n==)
- return ;
- return n/+(n%>=x)+get(n/,x);
- }
- int getx(int n,int x){
- if(n==)
- return ;
- int res =;
- res = getx(n/,x)+get(n,x);
- return res;
- }
- int main()
- {
- int n;
- while(cin>>n){
- int num2 = get2(n);
- int num5 = get5(n);
- int num3 = getx(n,);
- int num7 = getx(n,);
- int num9 = getx(n,);
- if(num2<num5){
- printf("%5d -> %d\n",n,);
- continue;
- }else{
- int res =;
- if(num2!=num5){
- num2 = num2-num5;
- res = res*s[][num2%];
- res = res%;
- }
- res *= s[][num3%];
- res %=;
- res *= s[][num7%];
- res %=;
- res *= s[][num9%];
- res = res%;
- printf("%5d -> %d\n",n,res);
- }
- }
- return ;
- }
poj 1604 Just the Facts的更多相关文章
- 最后一个非零数字(POJ 1604、POJ 1150、POJ 3406)
POJ中有些问题给出了一个长数字序列(即序列中的数字非常多),这个长数字序列的生成有一定的规律,要求求出这个长数字序列中某个位上的数字是多少.这种问题通过分析,找出规律就容易解决. 例如,N!是一个非 ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目分类(转)
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- POJ题目(转)
http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法: (1)枚举. (poj1753,poj29 ...
随机推荐
- JAVA FILE or I/O学习 - 补充CopyFiles功能
public class CopyFiles { public static void main(String[] args) { CopyFiles copyFiles = new CopyFile ...
- 动态调用python类和函数
类 class test1(object): def __init__(self): print "i am test1" class test2(object): def __i ...
- String、StringBuffer和StringBuild的区别
public class Test1 { public static void stringReplace (String text) { text = text.replace('j','i') ; ...
- 如何写出专业级OOP程序-----文档注释
由于时间的限制就写一些通用的注释啦> @author 姓名 这个标记将产生一个作者条目,可以使用多个@author注释,每个对应一个作者. @version 文本 这个标记产生版本条目,对当前版 ...
- SSIS: 使用Lookup 和 Cache transformation 进行数据匹配简单介绍
本文将讲解Cache transformation的使用方式,并且用Lookup transformation进行匹配. 背景 如下图,我们的产品目标表中有些有尺寸信息有些没有.我们需要用Cache组 ...
- C++对象模型6--对象模型对数据访问的影响
如何访问成员? 前面介绍了C++对象模型,下面介绍C++对象模型的对访问成员的影响.其实清楚了C++对象模型,就清楚了成员访问机制.下面分别针对数据成员和函数成员是如何访问到的,给出一个大致介绍. 对 ...
- 两种写法实现Session Scope的Spring Bean
xml based: <bean id="localRepository" class="com.demo.bean.LocalRepository" s ...
- SSL握手流程
一.SSL是什么? 安全套接字(SSL)协议是Web浏览器和Web服务器之间安全交换信息的协议. SSL介于应用层和TCP层之间,应用层数据不再直接传递给传输层,而是传递给SSL层,SSL层对从应用层 ...
- Page Cache, the Affair Between Memory and Files
Previously we looked at how the kernel manages virtual memory for a user process, but files and I/O ...
- asp.net mvc3 linq实现数据的增、删、改、查、
asp.net mvc 3 linq实现数据的增.删.改.查. 添加数据 定义一个对象: public class Student { public int id{get; set;} public ...