1. /**
  2. 大意: 求n! 结果 从左到右 第一个非零数
  3. 跟 1150 差不多。。
  4. **/
  5. #include <iostream>
  6. #include <cstdio>
  7. using namespace std;
  8.  
  9. int s[][]={
  10. {,,,},{,,,},{,,,},{,,,}
  11. };
  12. int get2(int n){
  13. if(n==)
  14. return ;
  15. return n/+get2(n/);
  16. }
  17.  
  18. int get5(int n){
  19. if(n==)
  20. return ;
  21. return n/+get5(n/);
  22. }
  23.  
  24. int get(int n,int x){
  25. if(n==)
  26. return ;
  27. return n/+(n%>=x)+get(n/,x);
  28. }
  29.  
  30. int getx(int n,int x){
  31. if(n==)
  32. return ;
  33. int res =;
  34. res = getx(n/,x)+get(n,x);
  35. return res;
  36. }
  37.  
  38. int main()
  39. {
  40. int n;
  41. while(cin>>n){
  42. int num2 = get2(n);
  43. int num5 = get5(n);
  44. int num3 = getx(n,);
  45. int num7 = getx(n,);
  46. int num9 = getx(n,);
  47. if(num2<num5){
  48. printf("%5d -> %d\n",n,);
  49. continue;
  50. }else{
  51. int res =;
  52. if(num2!=num5){
  53. num2 = num2-num5;
  54. res = res*s[][num2%];
  55. res = res%;
  56. }
  57. res *= s[][num3%];
  58. res %=;
  59. res *= s[][num7%];
  60. res %=;
  61. res *= s[][num9%];
  62. res = res%;
  63. printf("%5d -> %d\n",n,res);
  64. }
  65. }
  66. return ;
  67. }

poj 1604 Just the Facts的更多相关文章

  1. 最后一个非零数字(POJ 1604、POJ 1150、POJ 3406)

    POJ中有些问题给出了一个长数字序列(即序列中的数字非常多),这个长数字序列的生成有一定的规律,要求求出这个长数字序列中某个位上的数字是多少.这种问题通过分析,找出规律就容易解决. 例如,N!是一个非 ...

  2. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  3. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  4. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  5. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

  6. POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)

    本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...

  7. POJ题目分类(转)

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  9. POJ题目(转)

    http://www.cnblogs.com/kuangbin/archive/2011/07/29/2120667.html 初期:一.基本算法:     (1)枚举. (poj1753,poj29 ...

随机推荐

  1. JAVA FILE or I/O学习 - 补充CopyFiles功能

    public class CopyFiles { public static void main(String[] args) { CopyFiles copyFiles = new CopyFile ...

  2. 动态调用python类和函数

    类 class test1(object): def __init__(self): print "i am test1" class test2(object): def __i ...

  3. String、StringBuffer和StringBuild的区别

    public class Test1 { public static void stringReplace (String text) { text = text.replace('j','i') ; ...

  4. 如何写出专业级OOP程序-----文档注释

    由于时间的限制就写一些通用的注释啦> @author 姓名 这个标记将产生一个作者条目,可以使用多个@author注释,每个对应一个作者. @version 文本 这个标记产生版本条目,对当前版 ...

  5. SSIS: 使用Lookup 和 Cache transformation 进行数据匹配简单介绍

    本文将讲解Cache transformation的使用方式,并且用Lookup transformation进行匹配. 背景 如下图,我们的产品目标表中有些有尺寸信息有些没有.我们需要用Cache组 ...

  6. C++对象模型6--对象模型对数据访问的影响

    如何访问成员? 前面介绍了C++对象模型,下面介绍C++对象模型的对访问成员的影响.其实清楚了C++对象模型,就清楚了成员访问机制.下面分别针对数据成员和函数成员是如何访问到的,给出一个大致介绍. 对 ...

  7. 两种写法实现Session Scope的Spring Bean

    xml based: <bean id="localRepository" class="com.demo.bean.LocalRepository" s ...

  8. SSL握手流程

    一.SSL是什么? 安全套接字(SSL)协议是Web浏览器和Web服务器之间安全交换信息的协议. SSL介于应用层和TCP层之间,应用层数据不再直接传递给传输层,而是传递给SSL层,SSL层对从应用层 ...

  9. 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 ...

  10. asp.net mvc3 linq实现数据的增、删、改、查、

    asp.net mvc 3 linq实现数据的增.删.改.查. 添加数据 定义一个对象: public class Student { public int id{get; set;} public ...