UVA113 : https://uva.onlinejudge.org/external/1/113.pdf
/*math*/
/*
based on :
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main() {
// your code goes here
double n, p,k;
while (cin>>n>>p)
{
k = pow(p, 1.0 / n);
/*
Most probably the default number digit after decimal is 6, so in UVA compiler your ans. for
2
16
would be
4.000000 and not 4. reference
*/
printf("%.0lf\n", k);
}
system("PAUSE");
}
/*math*/
/*
based on :
kn = p (kn)(1/n) = p(1/n) k = p(1/n) /* k = pow(p,1/n) */*/
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main() {
// your code goes here
double n, p,k;
while (cin>>n>>p)
{
k = pow(p, 1.0 / n);
/*
Most probably the default number digit after decimal is 6, so in UVA compiler your ans. for
2
16
would be
4.000000 and not 4. reference
*/
printf("%.0lf\n", k);
}
system("PAUSE");
}
留言
張貼留言