Welcome to the Csdn-markdown Editor

Source: Internet
Author: User

A-power of Cryptography uva113

Time limit:3000ms Memory limit:0kb 64bit IO format:%lld &%llu
Submit Status Practice UVA 113
Appoint Description:
Background
Cryptography involves (among other things) large prime numbers and computing powers of numbers modulo func tions of these primes. resulted in the practical use of results from number theory and other branches of mathematics once C Onsidered to is of only theoretical interest.
This problem involves the efficient computation of the integer roots of numbers.
The problem
Given an integer tex2html_wrap_inline32 and an integer tex2html_wrap_inline34 you is to write a program that determines t Ex2html_wrap_inline36, the positive tex2html_wrap_inline38 root of P. In this problem, given such integers n and p, p'll always be the of the form tex2html_wrap_inline48 for a integer k (this I Nteger is, your program must find).
The Input
The input consists of a sequence of integer pairs N and p with each integer in a line by itself. For all such pairs tex2html_wrap_inline56, tex2html_wrap_inline58 and there exists an integer k, tex2html_wrap_inline62 s Uch that tex2html_wrap_inline64.
The Output
For each integer pair n and p the value tex2html_wrap_inline36 should is printed, i.e., the number k such that TEX2HTML_WR Ap_inline64.
Sample Input
2
16
3
27
7
4357186184021382204544
Sample Output
4
3
1234
Using the POW function to open P-square

#include <iostream>#include <algorithm>#include <map>#include <cstdio>#include <cstdlib>#include <vector>#include <cmath>#include <cstring>#include <string>using namespace STD;Const intmaxn=50005;typedef Long LongLL;intMain () {//freopen ("Text//in.txt", "R", stdin);    DoublePintN while(~scanf("%D%LF", &n,&p)) {printf("%.0lf\n",POW(P,1./n)); }return 0;}

Welcome to the Csdn-markdown Editor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.