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 n th. 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<10 101 and there exists an integer k, 1<=k<=10 9 such that k n = 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

  1. 2 16
  2. 3 27
  3. 7 4357186184021382204544

Sample Output

  1. 4
  2. 3
  3. 1234
  4.  
  5. 分析:这里注意一下p的取值范围,直接用double 就可以了,double 达到了1.797693e+308~ 4.9000000e-324
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<cstdio>
  4. #include<cmath>
  5. using namespace std;
  6.  
  7. int main(){
  8. int n,p;
  9. while(cin>>n>>p){
  10. cout<<pow(p,1.0/n)<<endl;
  11. }
  12. return ;
  13. }
  1.  

poj2109 【贪心】的更多相关文章

  1. BZOJ 1692: [Usaco2007 Dec]队列变换 [后缀数组 贪心]

    1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1383  Solved: 582[Submit][St ...

  2. HDOJ 1051. Wooden Sticks 贪心 结构体排序

    Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  3. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. BZOJ 1691: [Usaco2007 Dec]挑剔的美食家 [treap 贪心]

    1691: [Usaco2007 Dec]挑剔的美食家 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 786  Solved: 391[Submit][S ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【BZOJ-4245】OR-XOR 按位贪心

    4245: [ONTAK2015]OR-XOR Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 486  Solved: 266[Submit][Sta ...

  7. code vs 1098 均分纸牌(贪心)

    1098 均分纸牌 2002年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解   题目描述 Description 有 N 堆纸牌 ...

  8. 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心

    SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...

  9. 【贪心】HDU 1257

    HDU 1257 最少拦截系统 题意:中文题不解释. 思路:网上有说贪心有说DP,想法就是开一个数组存每个拦截系统当前最高能拦截的导弹高度.输入每个导弹高度的时候就开始处理,遍历每一个拦截系统,一旦最 ...

随机推荐

  1. mysql批量修改列名为小写

    --  bo_project_info 为表名 SELECT concat( 'alter table ', 'bo_project_info', ' change column ', COLUMN_ ...

  2. Spring Boot + Mybatis 实现动态数据源

    动态数据源 在很多具体应用场景的时候,我们需要用到动态数据源的情况,比如多租户的场景,系统登录时需要根据用户信息切换到用户对应的数据库.又比如业务A要访问A数据库,业务B要访问B数据库等,都可以使用动 ...

  3. 微信支付 python版

    需求: 微信打开商品列表页面-> 点击商品后直接显示付款页面-> 点击付款调用微信支付 说明 微信支付需要你申请了公众号(appid, key - 用于签名), 商户号(mch_id, A ...

  4. linux软连接

    linux软连接.类似window的快捷方式可以跨磁盘块(硬连接不可以). #软硬链接 ln -sf source target ln source target #硬链接不能跨分区 #批量解压文件 ...

  5. 关于Gerrit code review 介绍与安装

    代码审核(Code Review)是软件研发质量保障机制中非常重要的一环,但在实际项目执行过程中,却因为种种原因被Delay甚至是忽略.在实践中,给大家推荐一款免费.开放源代码的代码审查软件Gerri ...

  6. <转>SQL Server CROSS APPLY and OUTER APPLY

    Problem SQL Server 2005 introduced the APPLY operator, which is like a join clause and it allows joi ...

  7. ExpandableListView使用(三)-ScrollView嵌套ExpandableListView,列表显示不全

    前言 ScrollView嵌套ExpandableListView会出现ExpandableListView列表显示不全,目前比较好的方法是复写ExpandableListView,重写里面的onMe ...

  8. 原创科幻短篇《VR》

    近些年VR很火,现在似乎又降温了,那么问题来了:VR到底有前景吗?我农村来的读书又少看不清楚哇.近些年房地产很火,现在似乎还是很火,那么问题来了:房价到底会降吗?我农村来的读书又少看不清楚哇. 以下正 ...

  9. 基于Spring aop写的一个简单的耗时监控

    前言:毕业后应该有一两年没有好好的更新博客了,回头看看自己这一年,似乎少了太多的沉淀了.让自己做一个爱分享的人,好的知识点拿出来和大家一起分享,一起学习. 背景: 在做项目的时候,大家肯定都遇到对一些 ...

  10. iOS10.3 起,将支持应用内评分

    iOS10.3 起,将支持应用内评分. (2017-01-25,现在最高版本iOS10.2.1,Xcode 稳定版本Xcode8.2.1,Xcode Beta版本 Xcode8.3Beta(BW109 ...