More actions
imported>Unknown No edit summary |
(Table transclusion repair v1) |
||
| Line 1: | Line 1: | ||
== 소감 == | == 소감 == | ||
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 | if (p[i] == '\0') | ||
break; | break; | ||
} | } | ||
| Line 34: | Line 34: | ||
break; | break; | ||
temp *= 10; | temp *= 10; | ||
temp += (p | 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 | 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;
}