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. Fedora 下 安装 chrome

    一.下载安装包,安装 1.去google 下载安装包 2.终端下    运行命令:    rpm -ivh google-chrome-stable_current_i386.rpm 3.  出现如下 ...

  2. oc-02-NSLog使用

    #import <Foundation/Foundation.h> /* NSLog() : C语言中的 printf的增强版 作用: 向控制台输出打印数据. 增强的地方 : 打印时间 , ...

  3. mydumper原理5

    前言 之前介绍了Oracle官方的多线程逻辑导入导出工具mysqlpump,但已经操作过的同学会发现其多线程的单位还是表,换句话说, 单表依然是 单线程导出 .网易早已使用mydumper/myloa ...

  4. 带约束优化问题 拉格朗日 对偶问题 KKT条件

    转自:七月算法社区http://ask.julyedu.com/question/276 咨询:带约束优化问题 拉格朗日 对偶问题 KKT条件 关注 | 22 ... 咨询下各位,在机器学习相关内容中 ...

  5. java_log4j多文件配置

    今天配置了log4j中写多个文件的内容,配置了半天才搞出来,为了避免类似问题,写个博客吧. 首先说一下需求,每天要在7个文件夹中生成文件,文件格式为xxx.log.2000.01.01,自己开发个写文 ...

  6. 小白日记20:kali渗透测试之后渗透测试阶段(一)--上传工具

    后渗透测试阶段--上传工具 为防止管理员将漏洞补上后,我们无法再通过该漏洞控制对方主机,所以需要进行后渗透测试阶段 1.上传各种工具 2.提权:为了全面控制目标系统 3.擦除攻击痕迹:防止管理员通过日 ...

  7. JAVAMAIL手动发送邮件

    telnet smtp.sina.com 25ehlo hncu/*ehlo命令是SMTP邮件发送程序与SMTP邮件接收程序建立连接后必须发送的第一条SMTP命令,参数<domain>表示 ...

  8. java io文件学习笔记

    File f = new file("D:"+File.separator+"test.txt"); File.separator跨系统文件分隔符 f.crea ...

  9. C#当前应用程序路径及环境变量

    一.获取当前文件的路径 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName 获取模块的完整路径.可获得当前执行的 ...

  10. [课程相关]homework-05

    零.准备工作 队伍成员:梁杰,夏天晗,谢祖三. 周五晚上吃完饭,我们就开始了讨论. 这次的要求是写服务器,客户端以及游戏结果动态显示.很明显是三个部分,我们也就顺其自然, 一人一个部分.我负责服务器, ...