sgu154
来源:互联网 发布:lol个人数据carry查询 编辑:程序博客网 时间:2024/06/05 04:11
链接:http://acm.sgu.ru/problem.php?contest=0&problem=154
/***************************************************************Author: LuckyQueentime: 2011.12.05 20:15Problem solution: 简单的找规律加二分。注意到阶乘后面的0只能由 2*5得到,而2有很多,一次只要找出阶乘的结果能 被5整除几次,不二分会超时 悲催的不会写二分, 抄袭了K哥的代码***************************************************************/#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <cmath>using namespace std;int cal(int n){int num = 0;while (n){n /= 5;num += n;}return num;}int main(){int n, l, r, mid;bool flag;while (~scanf("%d", &n)){l = 1, r = 400000100;flag = false;while (l < r){mid = (l+r) / 2;int tp = cal(mid);if (tp > n)r = mid;else if (tp == n)r = mid, flag = true;else l = mid + 1;}if (flag)printf("%d\n", r);else puts("No solution");}return 0;}
LuckyQueen is the best!!!
- sgu154
- sgu154:Factorial
- sgu154(数论入门)
- SGU154 Factorial(结尾有多少0)
- SGU154 Factorial 【二分答案】【n!素因子分解】
- SGU154——Factorial (poj1401变形题——数论+二分)
- windows WDF驱动程序设计
- linux入门常用命令
- fatal error LNK1169: one or more multiply defined symbols found
- STM32F 好书推荐
- C#修改文件
- sgu154
- java基础加强 + xml + HTTP 笔记整理
- Android工程代码目录介绍
- RedHat_Linux环境下防火墙配置初级入门
- KDE与GNOME
- Mahout bayes分类器
- 12.material
- “MM云服务”吸引全球应用开发者掘金中国市场
- linux后台执行自定义oracle任务