sgu 154
Factorial
题意:能否找到一个数,它的阶乘后面0的个数为n?
数越大,阶乘后的0越多。用二分找。对于一个数x,它的阶乘,将小于等于它的数分解质因数。其中2的个数一定大于5的个数。因此计5的个数就是结果末尾0的个数。比它小的数有x/5个5的倍数,x/25个25的倍数。那么5的数量就是x/5+x/25......
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
using namespace std;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF;
lon arr[SZ]; lon getn(lon x)
{
lon res=;
for(int i=;i<=;++i)
{
res+=x/arr[i];
}
return res;
} int main()
{
//std::ios::sync_with_stdio(0);
//freopen("d:\\1.txt","r",stdin);
//for(;scanf("%d",&n)!=EOF;)
lon casenum;
//cin>>casenum;
//for(lon time=1;time<=casenum;++time)
{
lon n;
cin>>n;
arr[]=;
for(int i=;i<=;++i)arr[i]=arr[i-]*;
lon lo=,hi=1e12+;
for(;lo<hi;)
{
lon mid=(lo+hi)/;
if(getn(mid)<n)lo=mid+;
else hi=mid;
}
if(getn(lo)==n)cout<<lo<<endl;
else cout<<"No solution"<<endl;
}
return ;
}
sgu 154的更多相关文章
- SGU 154.Factorial
时间限制:0.25s 空间限制:4M 题意 你的任务是找到最小自然数 N, 使N!在十进制下包含 Q个零. 众所周知 N! = 1*2*...*N. 例如, 5! = 120, 120 结尾包含1个零 ...
- 今日SGU 5.4
SGU 127 题意:给你n个数字,和m,k,问你有多少个数字的m次幂可以被k整除 收获:快速幂 #include<bits/stdc++.h> #define de(x) cout< ...
- SGU 分类
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...
- 1Z0-053 争议题目解析154
1Z0-053 争议题目解析154 考试科目:1Z0-053 题库版本:V13.02 题库中原题为: 154.A database is running in ARCHIVELOG mode and ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- ACM: SGU 101 Domino- 欧拉回路-并查集
sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ...
- 【SGU】495. Kids and Prizes
http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...
- SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operati ...
- SGU 422 Fast Typing(概率DP)
题目大意 某人在打字机上打一个字符串,给出了他打每个字符出错的概率 q[i]. 打一个字符需要单位1的时间,删除一个字符也需要单位1的时间.在任意时刻,他可以花 t 的时间检查整个打出来的字符串,并且 ...
随机推荐
- uniGUI试用笔记(九)
uniGUI执行程序部署有3种形式 1.ISAPI模式 部署在IIS或Apache,程序编译为Dll形式,没有试,准备后续专门测试一下. 2.标准执行文件模式 将软件编译成一个独立的Exe文件,包括了 ...
- MATLAB小波包的分解与重构
该文章用来直观上先感受一下小波包的分解与重构 例1 有一个信号,变量名为wave,随便找一个信号load进来就行了. t=wpdec(wave,3,'dmey'); t2 = wpjoin(t,[ ...
- Css下拉菜单设置
<style type="text/css"> *{margin:0px;padding:0px;}设置所有标签属性<初始化页面属性> #nav{backg ...
- NLP related basic knowledge with deep learning methods
NLP related basic knowledge with deep learning methods 2017-06-22 First things first >>> ...
- kubernetes 实战2_命令_Configure Pods and Containers
--以yaml格式输出:pod\configmap\service\ingress\deployment kubectl get pod platform-financeapi-deployment- ...
- 微服务架构与实践4_Docker
构建Docker映像 定义Dockerfile=>Docker根据Dockerfile构建出映像 包含: 基础映像(父映像)信息 维护者信息 映像操作命令 容器启动命令 .net standar ...
- Footnotes for tables in latex - 为latex的table加上footnotes
参考: Footnotes for tables in LaTeX Footnote in tabular environment Footnotes for tables in latex - 为l ...
- C#调用cmd命令
using System.Diagnostics; public class CmdHelper { private static string CmdPath = @"C:\Windows ...
- 虚拟现实外包公司—北京动点飞扬软件承接VR/AR软件、游戏外包
欢迎通过以下方式联系北京动点飞扬软件外包业务咨询QQ:372900288 (全天在线) 咨询邮箱:SLteam@vip.qq.com 同时我们还承接 HTML5外包. kinect外包.Uni ...
- 【六】php 错误异常处理
错误异常处理 概念:代码在try代码块被调用执行,catch代码块捕获异常 异常需要手动抛出 throw new Exception (‘message’,code) throw将出发异常处理机制 在 ...