SDAU 1012
来源:互联网 发布:阿里云软件市场分成 编辑:程序博客网 时间:2024/06/08 15:06
Problem 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).
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
题目大意:
给定n m,现在n^p=m; 求p
思路:
如果是扫描查找的话,需要自己写出大数相乘的规则,显然是比较麻烦的。所以用数学知识转化一下的话,就比较简单了, p=m ^ 1/n
感想:
一开始感觉挺难得,后来小豆子给我提醒了一下,恍然大悟~
AC代码:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
0 0
- SDAU 1012
- SDAU课程练习1012
- sdau-2 1012
- SDAU dp专题 1012
- sdau三 1012
- SDAU课程练习2 1012
- 2016SDAU课程练习一 1012
- 2016SDAU课程练习一1012
- 2016SDAU编程练习二1012
- 2016sdau课程练习专题二 1012
- SDAU 练习三 1012 堆满骨牌问题
- 2016SDAU编程练习三1012
- 2016sdau课程练习专题三 1012
- 2016sdau课程练习专题三 1012
- 2016SDAU课程练习一1012 Problem M
- 2016sdau课程练习专题一 1012 problemM
- 2016SDAU课程练习三1012 Problem L
- SDAU 1000
- 开发中犯的低级错误。。。
- c++ <new定位运算符>与<显式调用析构函数> - 练习题
- 纯css实现尖角图形
- LeetCode-16.3Sum Closest
- CSS样式设置--水平居中
- SDAU 1012
- java运行环境的配置
- Final关键字
- 字符串
- android视图学习---Android中将布局文件/View添加至窗口过程分析 ---- 从setContentView()谈起
- 基于划分的聚类----K-means算法使用(R语言)
- java连接数据库时加载驱动程序Class.forName(driveName)详解
- 梳理caffe代码solver(十四)
- Android学习笔记---第四天---基础UI组件---RadioButton&CheckBox&ToggleButton&Switch---Button的子类