题目意思就是已知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. zookeeper(百度百科http://baike.baidu.com/view/3061646.htm?fr=aladdin)

    ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护.名字服务.分布式同步.组服务等.ZooKeeper的目标就是封装好复杂易出错的关键服务 ...

  2. golang gui library 库

    andlabs/ui已经重写,稳定性增强,但是组件很少,只提供了几种基础的控件,慎用.gxui死了,别用.linuxdeepin转QT了,所以…… windows系统最好的选择是walk. 首先,写w ...

  3. (转)Marathon健康检查

    健康检查是需要每个应用运行监控检查任务的. 1.默认的健康检查是延迟才能让mesos知道任务的状态是否健康. 2.marathon提供一个任务资源的健康成员访问的REST API接口. 如果HTTP的 ...

  4. [xdoj] 1301&1302 数字计数 数字计数的复仇

    1.首先需要掌握二进制数的一种特性,00=0,01=1,10=2,11=3.每一个二进制的值代表他前面的二进数的个数,比如11=3,他的前面就有三个二进制的数字,不过在本题中,题目数据是1-n,故把0 ...

  5. glibc源码下载

    https://www.gnu.org/software/libc/ Download sources Releases are available by source branch checkout ...

  6. HTTP通信机制

    HTTP通信机制是在一次完整的HTTP通信过程中,Web浏览器与Web服务器之间将完成下列7个步骤:  1. 建立TCP连接 在HTTP工作开始之前,Web浏览器首先要通过网络与Web服务器建立连接, ...

  7. php $_FILES上传失败 error返回值说明

    用PHP上传文件时,我们会用程序去监听浏览器发送过来的文件信息,首先会通 过$_FILES[fieldName]['error']的不同数值来判断此欲上传的文件状态是否正常. $_FILES[fiel ...

  8. webpack使用三

    Webpack的强大功能 生成Source Maps(使调试更容易) 开发总是离不开调试,方便的调试能极大的提高开发效率,不过有时候通过打包后的文件,你是不容易找到出错了的地方,对应的你写的代码的位置 ...

  9. bootstrap ui

    附加访问地址:http://www.bootcss.com/p/jquery-ui-bootstrap/

  10. UI界面之淡入淡出

    1.using UnityEngine; using System.Collections; using UnityEngine.UI; public class danrudanchu : Mono ...