/**
题目:Trailing Zeroes (III)
链接:https://vjudge.net/contest/154246#problem/N
题意:假设n!后面有x个0.现在要求的是,给定x,要求最小的n;
思路:判断一个n!后面有多少个0,通过n/5+n/25+n/125+...
*/ #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int maxn = *1e8+;
int num(int m)
{
int cnt = ;
while(m>){
cnt += m/;
m /= ;
}
return cnt;
}
int main()
{
int T, cas=, q;
cin>>T;
while(T--)
{
scanf("%d",&q);
int lo = , hi = maxn;
int m;
int mis = maxn;
while(lo<=hi){
m = (lo+hi)/;
int t = num(m);
if(t>=q){
if(t==q) mis = min(mis,m);
hi = m-;
}else
{
lo = m+;
}
}
if(mis==maxn)
printf("Case %d: impossible\n",cas++);
else
printf("Case %d: %d\n",cas++,mis); }
return ;
}

Trailing Zeroes (III) 假设n!后面有x个0.现在要求的是,给定x,要求最小的n; 判断一个n!后面有多少个0,通过n/5+n/25+n/125+...的更多相关文章

  1. Trailing Zeroes (III) -;lightoj 1138

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

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

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

  3. Trailing Zeroes (III)(lightoj 二分好题)

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

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

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

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

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

  6. LightOJ Trailing Zeroes (III) 1138【二分搜索+阶乘分解】

    1138 - Trailing Zeroes (III) PDF (English) problem=1138" style="color:rgb(79,107,114)" ...

  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. Trailing Zeroes (III) LightOJ - 1138(二分)

    You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in d ...

随机推荐

  1. 定时任务-crontab

     一.crond简介 crond 是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动c ...

  2. delphi设计浮动窗口

    delphi设计浮动窗口 用过Photoshop的朋友一定对它的那些方便的浮动面板记忆犹新,其实这些面板就是一个个的小窗体,但这些小窗体都放在Photoshop的主窗体上 (不是存在主窗体中),有自己 ...

  3. JS面向对象之原型

    面向对象之原型 为什么要使用原型 由于 js 是解释执行的语言, 那么在代码中出现的函数与对象, 如果重复执行, 那么会创建多个副本, 消耗更多的内存, 从而降低性能 传统构造函数的问题 functi ...

  4. mormot数据库连接+查询+序列为JSON

    mormot数据库连接+查询+序列为JSON uses SynDB,SynCommons, SynDBRemote, SynOleDB, SynDBMidasVCL, mORMotMidasVCL p ...

  5. 微信跳一跳 可以直接更改分数, POST 请求没有校验

    这两天逛 v 站出现了一众微信跳一跳 'AI',已经被刷屏了…… https://www.v2ex.com/t/418833 https://www.v2ex.com/t/418775 https:/ ...

  6. 【Docker安全】关于Docker使用root与非root用户的场景中的容器与host中的执行用户的研究

    参考: http://blog.csdn.net/yygydjkthh/article/details/47694929

  7. Selenium webdriver Java firefox 路径设置问题

    问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...

  8. Odoo8.0中允许用户动态调整TreeView栏位宽度

    现有的Odoo8.0中TreeView的栏位宽度是固定的,不可以手动调整,通过安装第三方插件后,可以实现手工动态调整. 下载模块安装即可.http://download.csdn.net/detail ...

  9. POJ 3221 Diamond Puzzle(BFS)

    Description A diamond puzzle is played on a tessellated hexagon like the one shown in Figure 1 below ...

  10. 一站式学习Wireshark(转载)

    一站式学习Wireshark(一):Wireshark基本用法 2014/06/10 · IT技术 · 4 评论 · WireShark 分享到: 115 与<YII框架>不得不说的故事— ...