U E D R , A S I H C RSS

Power Of Cryptography/문보창

소감

{{| 2005-07-29 Accepted 0.014 Minimum |}}

코드

~cpp 
// no 113 -  Power of Cryptography  
#include <iostream>
#include <math.h>
using namespace std;

const int LEN = 1001;

int find_length(char * p)
{
	int i;
	for (i = 0; ; i++)
	{
		if (p[i] == '\0')
			break;
	}
	return i;
}

// 가정 - 근사치만 구해도 된다.
double find_lnP(char * p)
{
	double lnP;
	int len = find_length(p);
	lnP = len - 1;

	double temp = 0;
	int i;
	for (i = 0; i < 15; i++)
	{
		if (i == len)
			break;
		temp *= 10;
		temp += (p[i] - '0');
	}	
	lnP += log10(double(temp) / pow(10, i-1));
	return lnP;
}

void process(int n, char * p)
{
	double lnP = find_lnP(p);
	double ex = lnP / n;
	double k = pow(10, ex);
	k += 0.5;
	int result = floor(k);
	cout << result << endl;
}

int main()
{
	int n;
	char p[LEN];
	while (cin >> n)
	{
		cin.get();
		cin.getline(p, LEN, '\n');
		process(n, p);
	}
	return 0;
}

나한테 할 말

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:24:01
Processing time 0.0087 sec