Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

PowerOfCryptography/문보창: Difference between revisions

From ZeroWiki
imported>Unknown
No edit summary
 
(Table transclusion repair v1)
 
Line 1: Line 1:
== 소감 ==
== 소감 ==
{{| 2005-07-29 Accepted  0.014  Minimum |}}
2005-07-29 Accepted  0.014  Minimum
== 코드 ==
== 코드 ==
  // no 113 -  Power of Cryptography   
  // no 113 -  Power of Cryptography   
Line 14: Line 14:
  for (i = 0; ; i++)
  for (i = 0; ; i++)
  {
  {
  if (p[i] == '\0')
  if (p[i] == '\0')
  break;
  break;
  }
  }
Line 34: Line 34:
  break;
  break;
  temp *= 10;
  temp *= 10;
  temp += (p[i] - '0');
  temp += (p[i] - '0');
  }
  }
  lnP += log10(double(temp) / pow(10, i-1));
  lnP += log10(double(temp) / pow(10, i-1));
Line 53: Line 53:
  {
  {
  int n;
  int n;
  char p[LEN];
  char p[LEN];
  while (cin >> n)
  while (cin >> n)
  {
  {
Line 65: Line 65:
----
----
[[PowerOfCryptography]] [[LittleAOI]]
[[PowerOfCryptography]] [[LittleAOI]]

Latest revision as of 12:46, 27 March 2026

소감

2005-07-29 Accepted  0.014  Minimum

코드

// 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;
}

나한테 할 말


PowerOfCryptography LittleAOI