Trailing Zeroes (III) 假设n!后面有x个0.现在要求的是,给定x,要求最小的n; 判断一个n!后面有多少个0,通过n/5+n/25+n/125+...
/**
题目: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+...的更多相关文章
- Trailing Zeroes (III) -;lightoj 1138
Trailing Zeroes (III) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Y ...
- light oj 1138 - Trailing Zeroes (III)【规律&&二分】
1138 - Trailing Zeroes (III) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- Trailing Zeroes (III)(lightoj 二分好题)
1138 - Trailing Zeroes (III) PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)
http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS M ...
- Light oj 1138 - Trailing Zeroes (III) 【二分查找 && N!中末尾连续0的个数】
1138 - Trailing Zeroes (III) problem=1138"> problem=1138&language=english&type=pdf&q ...
- LightOJ Trailing Zeroes (III) 1138【二分搜索+阶乘分解】
1138 - Trailing Zeroes (III) PDF (English) problem=1138" style="color:rgb(79,107,114)" ...
- 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 ...
- 1138 - Trailing Zeroes (III) 二分
1138 - Trailing Zeroes (III) You task is to find minimal natural number N, so that N! contains exa ...
- 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 ...
随机推荐
- Grunt上手指南(转)
Grunt , javascript 我想先花点时间回忆一下作为一个前端需要做的工作(Loading...) JS合并 JS压缩 CSS压缩 CSS Sprite 图片优化 测试 静态资源缓存(版本 ...
- Nginx 编译参数详解/大全
Nginx参数: –prefix= 指向安装目录 –sbin-path 指向(执行)程序文件(nginx) –conf-path= 指向配置文件(nginx.conf) –error-log-path ...
- 让IE浏览器支持HTML5
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- powerbuilder webbrowser 内嵌浏览器 select下拉框无法使用
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MA ...
- centos6.8下安装部署LNMP(备注:nginx1.8.0+php5.6.10+mysql5.6.12)
在平时运维工作中,经常需要用到LNMP应用框架.以下对LNMP环境部署记录下: 1)前期准备:为了安装顺利,建议先使用yum安装依赖库[root@opd ~]#yum install -y make ...
- 测试网站页面网速的Python脚本
一.测试网站页面网速脚本 [root@salt ~]# cat check_url.py #!/usr/bin/python # coding: UTF-8 import StringIO,pycur ...
- LWIP的移植笔记
第一次发表博客,文章摘录于还不懂同学的专栏 lwIp的作者做了大量的工作以方便像我这种懒人移植该协议栈,基本上只需修改一个配置头文件和改写3个函数即可完成lwIP的移植.要改写的函数位于lwIP-1. ...
- (转)MFC的GUI窗口使用Console输出函数printf
原文链接 在GUI程序中使用printf函数: #include <io.h> #include <fcntl.h> void InitConsole() { ; FILE* ...
- [转载] 在Linux中,开机自动运行普通用户的脚本程序
FROM:http://blog.csdn.net/sinboy/article/details/2466225 FROM:http://www.2cto.com/os/201006/50680.ht ...
- 2017.11.15 hashmap的工作原理
参考来自:http://blog.csdn.net/jeffleo/article/details/54946424 一 hashMap的基本概念 1.HashMap的定义 public class ...