1.Link:

http://poj.org/problem?id=2109

http://bailian.openjudge.cn/practice/2109/

2.Content:

Power of Cryptography
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 18872   Accepted: 9520

Description

Current work in cryptography involves (among other things) large prime numbers and computing powers of numbers among these primes. Work in this area has resulted in the practical use of results from number theory and other branches of mathematics once considered to be only of theoretical interest.
This problem involves the efficient computation of integer roots of numbers.

Given an integer n>=1 and an integer p>= 1 you have to write a
program that determines the n th positive root of p. In this problem,
given such integers n and p, p will always be of the form k to the nth. power, for an integer k (this integer is what your program must find).

Input

The
input consists of a sequence of integer pairs n and p with each integer
on a line by itself. For all such pairs 1<=n<= 200, 1<=p<10101 and there exists an integer k, 1<=k<=109 such that kn = p.

Output

For each integer pair n and p the value k should be printed, i.e., the number k such that k n =p.

Sample Input

2 16
3 27
7 4357186184021382204544

Sample Output

4
3
1234

Source

3.Method:

推导过程:

K^N = P

logk P = N

log(P) / log(k) = N (换底公式)

log(K) = 1/N * log(P)

K = e ^ ( 1/N * log(P)) = ( e ^ log(P)) ^ (1/N) = P ^ (1/N) = pow(P,1/N)

因此采用double读入,会损失部分精度,但是这题貌似精度没有那么高,所以可行

4.Code:

 #include <iostream>
#include <cstdio>
#include <cmath> using namespace std; int main()
{
//freopen("D://input.txt","r",stdin); double p,n; while(cin >> n >> p)
{
cout << pow(p,1.0/n) << endl;
} return ;
}

5.Reference:

Poj 2109 / OpenJudge 2109 Power of Cryptography的更多相关文章

  1. 贪心 POJ 2109 Power of Cryptography

    题目地址:http://poj.org/problem?id=2109 /* 题意:k ^ n = p,求k 1. double + pow:因为double装得下p,k = pow (p, 1 / ...

  2. poj 2109 Power of Cryptography

    点击打开链接 Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16388   Ac ...

  3. POJ 2109 :Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 18258   Accepted: ...

  4. POJ 2109 -- Power of Cryptography

    Power of Cryptography Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 26622   Accepted: ...

  5. POJ 2109 Power of Cryptography 数学题 double和float精度和范围

    Power of Cryptography Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21354 Accepted: 107 ...

  6. Power of Cryptography(用double的泰勒公式可行分析)

    Power of Cryptography Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onli ...

  7. [POJ2109]Power of Cryptography

    [POJ2109]Power of Cryptography 试题描述 Current work in cryptography involves (among other things) large ...

  8. UVA 113 Power of Cryptography (数学)

    Power of Cryptography  Background Current work in cryptography involves (among other things) large p ...

  9. POJ2109——Power of Cryptography

    Power of Cryptography DescriptionCurrent work in cryptography involves (among other things) large pr ...

随机推荐

  1. 苹果ipa软件包破解笔记

    苹果的验证机制: Appstore上的应用都採用了DRM(digital rights management)数字版权加密保护技术,直接的表现是A帐号购买的app,除A外的帐号无法使用,事实上就是有了 ...

  2. Chronometer控件实现的Android计时器

    本文为大家演示了如何使用Chronometer控件实现Android计时器的实例. 先贴上最终的实现效果图: Android计时器实现思路 使用Chronometer控件实现计器的操作.通过设置set ...

  3. iOS开发——UI篇OC篇&UITableView简单封装

    UITableView简单封装 UITableView时iOS开发中使用最多也是最重的一个UI空间,其实在App Store里面的%80以上的应用都用到了这个控件,所以就给大家介绍一下,前面的文章中也 ...

  4. Android下将图片载入到内存中

    Android的系统的标准默认每一个应用程序分配的内存是16M.所以来说是很宝贵的,在创建应用的时候要尽可能的去节省内存,可是在载入一些大的文件的时候,比方图片是相当耗内存的,一个1.3M的图片,分辨 ...

  5. Python 学习之二:Python超短教程

    前言 本教程综合Stanford CS231N和UC Berkerley CS188的Python教程. 教程非常短,但适合有一定编程基础.学过其它语言的童鞋. Python 启动Python 解释器 ...

  6. yii user 组件

    yii/web/user enableAutoLogin:如果未登录,则会从cookie中登录 autoRenewCookie: 如果登录了,则会使用renewIdentityCookie更新cook ...

  7. 【ZZ】Java : 一个帝国的诞生 & 假如时光能够倒流, 我会这么学习Java

    Java : 一个帝国的诞生 http://dy.qq.com/article.htm?id=20160523A06XFS00 写的很有意思,一下子了解了JAVA的历史. 假如时光能够倒流, 我会这么 ...

  8. hdu1051 Wooden Sticks

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1051 大意:求最少升序序列的个数. #include <cstdio> #include &l ...

  9. MSSQL系统表常用操作

    1:获取当前数据库中的所有用户表 select Name from sysobjects where xtype='u' and status>=0 2:获取某一个表的所有字段 select n ...

  10. 【shell】if

    if [ condition ];then action fi 运算符 描述 示例 文件比较运算符 -e filename 如果 filename存在,则为真 [ -e /var/log/syslog ...