Page 1 of 11
113 - Power of Cryptography
Posted: Mon Jun 10, 2002 5:21 pm
by rickyok
Hi, I'm a newby here
Please help me on this case
I can easly make a function for search k for input :
2
16
3
27
But it goes to error when i got input like
7
4357186184021382204544
Any ideas how i can handle very2 large integer
(Without using float/ double) coz i've tried double
and have no used against very large int.
Thank you
PLease reply
Posted: Mon Jun 10, 2002 10:08 pm
by ithamar
Implement your own routines to work with BigNumbers. Its not that hard

. Strings is the answer ...
Posted: Tue Jun 11, 2002 4:00 am
by skylander
you do not need to use string arithmetic, just some formula and a double will do the job...
Posted: Tue Jun 11, 2002 6:05 am
by rickyok
Well i've tried the string arithmathic but i failed
Becaused is not so simple to put a number into string and calculate a divide operation.
To Skylander:
Can you explain to me a little bit about that "Some formula and a double"
Thank you
Posted: Tue Jun 11, 2002 9:21 am
by C8H10N4O2
This entire problem is just one math equation. If I tell you the equation, then there is NO problem:p But here's a hint, think about logarithms...
problem 113 - complier error
Posted: Tue Jul 02, 2002 5:53 pm
by norton
Hi.
I have a problem with program no. 113. I posted it for many times but I always get compiler eror as the answer. I don't see what's wrong with the source code cause it works perfectly on my computer.
Here is the source code and the compiler's messages i received from the judge:
"@begin_of_source_code"
/* @JUDGE_ID: 10427NY 113 C */
#include <stdio.h>
#include <string.h>
#include <math.h>
long koren(char stev1[], char stev2[]);
int main(void)
{
char stev1[3];
char niz[102];
char stev2[102];
int i = 0;
while (scanf("%s", niz) == 1) {
i++;
if(i % 2 == 1) strcpy(stev1, niz);
else {
strcpy(stev2, niz);
printf("%ld\n", koren(stev1, stev2));
}
}
return 0;
}
long koren(char stev1[], char stev2[]) {
int j, mesta, eksp = 0;
long vsota = 0;
double osnova = 0;
for(j = 0; j < strlen(stev1) - 1; j++) {
eksp += (stev1[j] - '0') * pow(10, strlen(stev1) - 1 - j);
}
eksp += (stev1[j] - '0');
mesta = strlen(stev2) - 1;
if(mesta <

{
for(j = 0; j < mesta; j++) {
osnova += (stev2[j] - '0') * pow(10, mesta - j);
}
osnova += (stev2[j] - '0');
mesta = 0;
}
else {
for(j = 0; j < 8; j++) {
vsota += (stev2[j] - '0') * pow(10, 8 - j);
}
vsota += (stev2[j] - '0');
osnova = (double)vsota / pow(10,

;
}
return (long)(pow(10, (log10(osnova) + mesta) / eksp) + 0.5);
}
"@end_of_source_code"
Here are the compiler error messages:
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
--
Can anyone help please?
Thanks.
Posted: Tue Jul 02, 2002 6:02 pm
by Picard
strange. the judge compiled it for me (but wrong answer). maybe your mailer screw it up? btw this is a linker error after compiling, for some reason the main() function was not found.
prob 113
Posted: Wed Jul 10, 2002 8:16 am
by taj79
I want some hint...
i m unable to read the sample data(which one is really big....even with double )
Plz tell me what should I do?
Posted: Wed Jul 10, 2002 10:04 am
by visser
Do you really need that much precision to get the correct answer?
Posted: Wed Jul 10, 2002 11:54 am
by taj79
can u give me some tips how to attack the problem?if i can't read the number by scanf using a double variable how will i start?
Posted: Wed Jul 10, 2002 1:22 pm
by Picard
just read the older topics about P113
(this is what you should do first before creating a new topic...)
HERE IS THE SOLUTION IN ALGORITHM WAY....(CODE IT)
Posted: Tue Jul 23, 2002 9:35 am
by NONAME_SUST
HELLO,
The problem has a very simple solution. After viewing the problem you may say How easy!!! You know that c++ has a library named <<math.h>> . We will use this library to solve the problem. Here it is:
long double s = pow (p,1/n);
printf("%lf",s);
And thats it.........
Posted: Wed Jul 24, 2002 1:05 pm
by taj79
But my problem is reading p when it is big.
Code: Select all
#include<stdio.h>
#include<stdlib.h>
main()
{int d;
long double p;
scanf("%f",p);
printf("%0.0f",p);
}
For the sample input I m failing to read the input.....[/code]
Posted: Wed Jul 24, 2002 2:01 pm
by Ivor
When you read double you must use %lf instead of %f. The latter will only read a float value. For long double I suppose you should use %Lf.
Not sure myself.
Ivor
Posted: Wed Jul 24, 2002 3:03 pm
by taj79
The problem is still there whether i use %lf or %Lf
I m unable to read the long sample input.