题目意思就是已知n的阶乘,求n。

当输入的阶乘小于10位数的时候,我们可以用long long将字符串转化成数字,直接计算。

而当输入的阶乘很大的时候,我们就可以利用位数去大概的估计n。

 //Asimple
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, num, res, ans, len;string str;
void input() {
cin >> str;
len = str.size();
if( len < ) {
ll i = ;
ll ans = ;
while( true ) {
ans *= i;
if( ans == atoi(str.c_str()) ) {
cout << i;
break;
}
i ++;
}
} else {
ll i = ;
double ans = ;
while( true ) {
ans += log10(i);
if( floor(ans)==len ) {
cout << i;
break;
}
i ++;
}
}
} int main(){
input();
return ;
}

Kattis之旅——Inverse Factorial的更多相关文章

  1. Kattis之旅——Factovisors

    The factorial function, n! is defined thus for n a non-negative integer: 0! = 1 n! = n * (n-1)! (n & ...

  2. Kattis之旅——Prime Reduction

    A prime number p≥2 is an integer which is evenly divisible by only two integers: 1 and p. A composit ...

  3. Kattis之旅——Chinese Remainder

    Input The first line of input consists of an integers T where 1≤T≤1000, the number of test cases. Th ...

  4. Kattis之旅——Fractional Lotion

    Freddy practices various kinds of alternative medicine, such as homeopathy. This practice is based o ...

  5. Kattis之旅——Rational Arithmetic

    Input The first line of input contains one integer, giving the number of operations to perform. Then ...

  6. Kattis之旅——Number Sets

    You start with a sequence of consecutive integers. You want to group them into sets. You are given t ...

  7. Kattis之旅——Divisible Subsequences

    Given a sequence of positive integers, count all contiguous subsequences (sometimes called substring ...

  8. Kattis之旅——Prime Path

    The ministers of the cabinet were quite upset by the message from the Chief of Security stating that ...

  9. Kattis之旅——Perfect Pth Powers

    We say that x is a perfect square if, for some integer b, x = b2. Similarly, x is a perfect cube if, ...

随机推荐

  1. rpm: /root/anaconda3/lib/liblzma.so.5: version `XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)

    报如上的错误,发现rpm相关的命令都不能够用. 1.搜到这篇文章,https://stackoverflow.com/questions/47633870/rpm-lib64-liblzma-so-5 ...

  2. javaScript 数组迭代方法

    map 方法 解释:map即映射,返回对每项操作后组成的新数组 let arr=[1,2,3,4,5,6,7,8]; let newArr=arr.map((item)=>{ if(item&g ...

  3. 网络编程——socket编程

    一.客户端/服务端架构 1.硬件C/S架构(打印机) 2.软件C/S架构 互联网企业处处是C/S架构 C/S架构与socket的关系:学习socket就是为了完成C/S架构的开发 二.OSI七层 一个 ...

  4. Windows PyCharm永久激活

    1.下载 链接: https://pan.baidu.com/s/1LvQozk5lXdyk2p8qgGsr3A 提取码: x1t5 放置到 pycharm安装目录的\bin目录下(位置可随意,只要配 ...

  5. [LeetCode] 490. The Maze_Medium tag: BFS/DFS

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolli ...

  6. Hadoop.之.入门部署

    一.课程目标 ->大数据是什么?大数据能做什么? ->什么是Hadoop?Hadoop的设计思想? ->Hadoop如何解决大数据的问题?(什么是hdfs与yarn.MapReduc ...

  7. nodejs+react使用webpack打包时控制台报错

    一.错误:Uncaught ReferenceError: process is not defined 解决方法: new webpack.DefinePlugin({ 'process.env': ...

  8. ssh简单入门级案例教程

    准备工作:struts2.3.34+spring4.2.2+hibernate3.3.2 导入需要的开发包: struts开发包---注意:javassist-3.18.1-GA.jar包与hiber ...

  9. lumisoft.net 邮件管理系列文章 - 如何判断附件为内嵌式还是附加式

    如果要区分邮件里面的附件是内嵌图片附件还是真正的附件,那么可以通过下面代码进行判断,如果是MIME_DispositionTypes.Attachment的就是普通附件,MIME_Dispositio ...

  10. gpg无法生成密钥对的问题

    今天在archlinux中生成key的过程中,发现卡在收集随机信息的步骤了. 而在windows系统中启动kleopatra之后,一直是一个任务条,显示loading certificate cach ...