113 - Power of Cryptography
Moderator: Board moderators
113 - Power of Cryptography
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
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
problem 113 - complier error
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.
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.
prob 113
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?
i m unable to read the sample data(which one is really big....even with double )
Plz tell me what should I do?
-
- New poster
- Posts: 8
- Joined: Tue Jul 23, 2002 9:15 am
HERE IS THE SOLUTION IN ALGORITHM WAY....(CODE IT)
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.........
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.........
HEY WANT TO GET SOL.TRY ON http://www.uvexam.zzn.com from 1st September
But my problem is reading p when it is big.
For the sample input I m failing to read the input.....[/code]
Code: Select all
#include<stdio.h>
#include<stdlib.h>
main()
{int d;
long double p;
scanf("%f",p);
printf("%0.0f",p);
}