就是统计5,然后当时因为发现最多有8000w个5的倍数,然后8000w/100,是80w,打表,二分找

然后我看网上的都是直接二分找,真是厉害

#include <cstdio>
#include <iostream>
#include <ctime>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int N=1e8;
const int INF=0x3f3f3f3f;
int cnt[],a[];
int main()
{
int ans=,pos=;
for(int i=,j=;;i+=,++j){
int t=i;
while(t%==)++ans,t/=;
if(ans>=N){
break;
}
if(j%==){
cnt[++pos]=ans;
a[pos]=i;
}
}
cnt[++pos]=N+;
a[pos]=*N+;
int cas=,T;
scanf("%d",&T);
while(T--){
int n,res=-;
scanf("%d",&n);
int k=lower_bound(cnt+,cnt++pos,n)-cnt;
if(cnt[k]==n)res=a[k];
else {
--k;
int l=,sum=;
if(k!=)l=a[k]+,sum=cnt[k];
for(;l<a[k+];l+=){
int t=l;
while(t%==)t/=,++sum;
if(sum>=n){
break;
}
}
if(sum==n)res=l;
}
printf("Case %d: ",++cas);
if(res==-)printf("impossible\n");
else printf("%d\n",res);
}
return ;
}

LightOJ 1138 Trailing Zeroes (III) 打表的更多相关文章

  1. LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

    http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     M ...

  2. LightOj 1138 - Trailing Zeroes (III) 阶乘末尾0的个数 & 二分

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1138 题意:给你一个数n,然后找个一个最小的数x,使得x!的末尾有n个0:如果没有输出 ...

  3. lightoj 1138 - Trailing Zeroes (III)【二分】

    题目链接:http://lightoj.com/volume_showproblem.php? problem=1138 题意:问 N. 末尾 0 的个数为 Q 个的数是什么? 解法:二分枚举N,由于 ...

  4. LightOj 1138 Trailing Zeroes (III)

    题目描述: 假设有一个数n,它的阶乘末尾有Q个零,现在给出Q,问n最小为多少? 解题思路: 由于数字末尾的零等于min(因子2的个数,因子5的个数),又因为2<5,那么假设有一无限大的数n,n= ...

  5. light oj 1138 - Trailing Zeroes (III)【规律&&二分】

    1138 - Trailing Zeroes (III)   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit:  ...

  6. Light oj 1138 - Trailing Zeroes (III) 【二分查找 &amp;&amp; N!中末尾连续0的个数】

    1138 - Trailing Zeroes (III) problem=1138"> problem=1138&language=english&type=pdf&q ...

  7. Light oj 1138 - Trailing Zeroes (III) 【二分查找好题】【 给出N!末尾有连续的Q个0,让你求最小的N】

    1138 - Trailing Zeroes (III) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  8. 1138 - Trailing Zeroes (III) 二分

    1138 - Trailing Zeroes (III)   You task is to find minimal natural number N, so that N! contains exa ...

  9. Light oj 1138 - Trailing Zeroes (III) (二分)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1138 题目就是给你一个数表示N!结果后面的0的个数,然后让你求出最小的N. 我们可以知 ...

随机推荐

  1. mui 重写back 调用back方法,实现返回就即时刷新页面

    需求: 从A-----b页面  B操作完后再返回A ,这时A页面数据变化 1.先是针对安卓机可以点击按钮返回,也可以用本机的返回键返回 监听本机的返回按钮,如果点击就调用写好的自定义刷新事件 (fun ...

  2. Unity3D--学习太空射击游戏制作(三)

    步骤四:创建敌人 创建敌人的方式与创建主角类似,不过敌人的行为需要由计算机来控制,它将从上方迎着主角缓慢飞出来,并左右来回移动: 01:创建Enemy.cs脚本,添加代码: using UnityEn ...

  3. 【3】Bootstrap的下载和目录结构

    [1]下载 去中方官网下载http://www.bootcss.com/ 如果你是做网页练习,你可以使用CDN加速服务,免去下载等痛苦,当然你使用的时候必须有连接上网络.中方的官网也提供了很多种类的C ...

  4. platform平台设备驱动简化示例代码

    driver.c: #include <linux/kernel.h> #include <linux/module.h> #include <linux/init.h& ...

  5. Python中使用ElementTree解析xml

    在Python中,ElementTree是我们常用的一个解析XML的模块 1.导入ElementTree模块 from xml.etree import ElementTree as ET 2.初始化 ...

  6. Vijos P1063 迎春舞会之交谊舞 DP

    题目链接:https://vijos.org/p/1063 题意:有n(n <= 100)行,每行有2*i-1个可显字符'#'与'-',组成一个倒三角形,问由'-'组成的最大三角形的'-'的个数 ...

  7. shell写的计算器

    #!/bin/bashif [ $# -ne 3 ] then echo "Usage: $0 num1 + num2" fi case $2 in +) echo $1$2$3= ...

  8. Java学习--封装、继承、多态

    接下来几天会根据http://www.cnblogs.com/chenssy/category/525010.html中讲解的java内容做个学习笔记,在此感谢一下这位大仙!! 一.封装 对于封装而言 ...

  9. Linux下STM32开发环境的搭建

    目录 一.概述 1.目的 2.开发环境描述 3.Eclipse构建的STM32集成开发环境结构 4.GDB / GDB Server 调试模型 二.搭建步骤 三.详细的搭建过程 1.安装eclipse ...

  10. Appdelegate 导航操作

    隐藏返回按钮 self.navigationItem.hidesBackButton = YES; 设置导航的透明度 self.navigationController.navigationBar.t ...