Page 10 of 11
113 why not AC?
Posted: Thu Jul 29, 2010 9:08 am
by @mjad
please help me
Code: Select all
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
long double f,s,t;
//freopen("in.txt","r",stdin);
while(scanf("%lf%lf",&f,&s)==2)
{
t=exp(log(s)/f);
printf("%.0lf\n",t);
}
return 0;
}
Re: 113 whats my problem? please help me
Posted: Thu Jul 29, 2010 2:41 pm
by Hobby
please :
printf("%ld",...)
Re: 113 whats my problem? please help me
Posted: Sat Jul 31, 2010 7:03 am
by @mjad
thanks hobby
but i did not get AC
it always WA
please help me, Specific way?
Re: 113 whats my problem? please help me
Posted: Sat Jul 31, 2010 4:02 pm
by shaon_cse_cu08
There is no problem in outputting with "%.0f" .... Just take a look at the problem carefully...
"For all such pairs 1<=n<=200 and the other condition's ...."
Try this input....
-4
16
0
56
0
0
Ur program alsways generates... 1 or 0 for this cases.... there will be no output for this
To test ur input and output try "
http://uvatoolkit.com/"...
Hope That works... And don't open new Thread....if there is already one.....PLZZZ

Re: 113 why not AC?
Posted: Sat Jul 31, 2010 8:44 pm
by zobayer
You got WA because your solution is not correct, (I guess precision error)
For double data types, try to minimize the level of computation as more calculation will give you more errors.
Re: 113 why not AC?
Posted: Sun Aug 01, 2010 8:29 am
by shaon_cse_cu08
Re: 113 why not AC?
Posted: Sun Dec 26, 2010 3:38 am
by Trarex
Can someone say me about mistakes in my code? There should not be any problems with vars range (I've used float and double). So where can the problem hide?
Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float n;
double p;
while (cin >> n >> p) cout << exp(log(p) / n) << endl;
return 0;
}
Lately I modified the code in the next way:
Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float n;
double p;
while (cin >> n >> p) cout << long(exp(log(p)/n)) << endl;
return 0;
}
What is wrong?

Re: 113 why not AC?
Posted: Sun Dec 26, 2010 11:48 am
by sir. manuel
try with pow(p,1/n)
Re: 113 why not AC?
Posted: Sun Dec 26, 2010 12:10 pm
by Trarex
WA ;(
Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
float n;
double p;
cout.precision(0);
//while (cin >> n >> p) cout << long(exp(log(p)/n)) << endl;
while (cin >> n >> p) cout << long(pow(p,1/n)) << endl;
return 0;
}
Re: 113 why not AC?
Posted: Mon Dec 27, 2010 8:49 pm
by sir. manuel
Code: Select all
#include<stdio.h>
#include<math.h>
int main()
{
double a,b;
while(scanf("%lf %lf",&a,&b)==2){
printf("%.0lf\n",pow(b,1/a));
}
return 0;
}
Always use double!!!
Re: 113 why not AC?
Posted: Mon Dec 27, 2010 9:09 pm
by Trarex
and your solution has been accepted?
I've tried this one, but still WA
Code: Select all
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
//float n;
double n,p;
cout.precision(0);
//while (cin >> n >> p) cout << long(exp(log(p)/n)) << endl;
while (cin >> n >> p) cout << long(pow(p,1/n)) << endl;
return 0;
}
113 precision
Posted: Thu May 17, 2012 10:02 pm
by foo
Hi,
I just did problem '113 - Power of Cryptography', using the simple pow(p, 1/n) technique.
Though I don't quite see how this can be correct, as <= p <= 10^101 .
Isn't this too big for a double? For ex in java:
double d = Double.parseDouble("4357186184021382204544");
System.out.println(d); // outputs 4.357186184021382E21, major precision loss?
So shouldn't taking the square root of this number then give an incorrect answer?
thanks
Re: 113 precision
Posted: Thu May 17, 2012 11:32 pm
by brianfry713
double has enough precision for the I/O in the judge for this problem.
You are only taking the square root if n is 2.
113 - wrong answer
Posted: Thu Aug 09, 2012 5:19 pm
by BlâckFoX
Hii can anyone help me?
I submitted this ,but the judge kept saying i have wrong answer =( please help
#include <iostream>
#include <math.h>
using namespace std;
int main(){
double n, p;
double ans;
while(cin >> n >> p){
ans= pow(p,1/n);
cout << round(ans) << endl;
}
return 0;
}
Re: 113 - wrong answer
Posted: Fri Aug 10, 2012 5:58 am
by brianfry713
Try printing only the integer portion instead of using round().