/**
题目: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. 选择改变事件OnCheckedChange

    1.效果图:选择正确的提示选对,选择错误提示选错 2.activity_main.xml <?xml version="1.0" encoding="utf-8&q ...

  2. <摘录>字节对齐(强制对齐以及自然对齐)

    struct {}node; 32为的x86,window下VC下sizeof(node)的值为1,而linux的gcc下值为0: 一.WINDOWS下(VC--其实GCC和其原理基本一样,象这种问题 ...

  3. 学习Microsoft SQL Server 2008技术内幕:T-SQL语法基础

    第 2 章: 单表查询 use TSQLFundamentals2008; select * from Sales.orders; select empid, year(orderdate) as o ...

  4. IIS中使用Microsoft.Office.Interop.Excel 常见问题:RPC 服务器不可用。 (异常来自 HRESULT:0x800706BA) 的异常。等

    IIS中使用Microsoft.Office.Interop.Excel 异常1: 检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} ...

  5. webpack配置构建环境问题汇总

    环境:node 6.9.5  npm 3.10.10 问题一:Module build failed: TypeError: Path must be a string. Received undef ...

  6. opengl中VAO,VBO,IBO用法小结(zz) 【转】

    http://cowboy.1988.blog.163.com/blog/static/751057982014380251300/ opengl中VAO,VBO,IBO用法小结 这三个玩意全面取代旧 ...

  7. python 推导式(Comprehensions)

    一.介绍 列表推导(list comprehensions) 这是一种将for循环.if表达式以及赋值语句放到单一语句中的一种方法.换句话说,你能够通过一个表达式对一个列表做映射或过滤操作. 一个列表 ...

  8. mssql性能优化

    总结下SQL SERVER数据库性能优化相关的注意事项,在网上搜索了一下,发现很多文章,有的都列出了上百条,但是仔细看发现,有很多似是而非或者过时(可能对SQL SERVER6.5以前的版本或者ORA ...

  9. $ 和getElementId的区别 / 一个jquery对象的原型

    请说出 div 和 $div 的联系和区别 区别 div 返回一个HTML DOM Object $div 返回一个 jQuery Object, 两者不等价 $div是包装了dom对象后产生的,无法 ...

  10. 倍福TwinCAT(贝福Beckhoff)应用教程13.1 TwinCAT控制松下伺服 NC高级

    本节主要演示了使用自定义函数实现电机的运动(梯形曲线和S曲线都有实现),这里的JOG+和JOG-,针对单个关节实现了PTP的运动(跟贝福的MoveAbsolute功能块实现效果一致),在此没有介绍运动 ...