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 ...
随机推荐
- 语言基础之description方法
1.description方法的一般用处 1: // 指针变量的地址 2: NSLog(@"%p", &p); 3: // 对象的地址 4: NSLog(@"%p ...
- 【Node.js】3.Node.js和commomJS规范
来源:http://javascript.ruanyifeng.com/ 目录 概述 module对象 module.exports属性 exports变量 AMD规范与CommonJS规范的兼容性 ...
- Swift,枚举
枚举类型判断 1.设置并利用枚举 enum Weacher{ case a case b case c } var d=Weacher.b switch d{ case .a: print(" ...
- webservice ssl双向认证配置
1.在tomcat中安装axis2插件 2.生成证书,用jdk自带的keytool 服务端 keytool -genkey -alias Server -dname "CN=192.168. ...
- ubuntu i3 xterm中文输入显示问题解决
i3config 配置 !启动fcitx输入法管理 exec fcitx -d Xresource配置 !设置输入法管理器为fcitx xterm*inputMethod: fcitx !设置英文字体 ...
- 查看tomcat启动文件都干点啥---catalina.bat
在上一次查看tomcat启动文件都干点啥一文中,我们总结出,startup.bat文件的作用就是找到catalina.bat文件,然后把参数传递给它,在startup.bat中,调用catalina. ...
- 经典SQL语句使用方法大全
一.基础1.说明:创建数据库CREATE DATABASE database-name2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备份数 ...
- 冲销会计凭证:FBRP与FB08的区别
FBRA一般是用来对已经清帐的凭证进行冲销的,我们知道普通的冲销只要用FB08就可以了,但是对于已经被清帐和凭证,我们只能用FBRA来进行清帐,我们来按以下的没测试来做验证一下.STEP1:用F-22 ...
- html 5 中的 6位 十六进制颜色码 代表的意思180313
人的眼睛看到的颜色有两种: ⒈ 一种是发光体发出的颜色,比如计算机显示器屏幕显示的颜色: ⒉ 另一种是物体本身不发光,而是反射的光产生 的颜色,比如看报纸和杂志上的颜色. 我们又知道任何颜色都是由 ...
- WSDL接口数据传递以及外网发布需要注意的地方
A系统传递数据给B系统 1.A创建asmx推送接口如下 using System; using System.Collection.Generic; using System.Data; using ...