All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
@mjad
New poster
Posts: 44 Joined: Thu Jul 22, 2010 9:42 am
Post
by @mjad » Thu Jul 29, 2010 9:08 am
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;
}
Hobby
New poster
Posts: 4 Joined: Thu Jul 29, 2010 2:35 pm
Post
by Hobby » Thu Jul 29, 2010 2:41 pm
please :
printf("%ld",...)
@mjad
New poster
Posts: 44 Joined: Thu Jul 22, 2010 9:42 am
Post
by @mjad » Sat Jul 31, 2010 7:03 am
thanks hobby
but i did not get AC
it always WA
please help me, Specific way?
shaon_cse_cu08
New poster
Posts: 50 Joined: Tue May 25, 2010 9:10 am
Contact:
Post
by shaon_cse_cu08 » Sat Jul 31, 2010 4:02 pm
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
I'll keep holding on...Until the walls come tumbling down...And freedom is all around .....
zobayer
Experienced poster
Posts: 110 Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh
Contact:
Post
by zobayer » Sat Jul 31, 2010 8:44 pm
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.
You should not always say what you know, but you should always know what you say.
shaon_cse_cu08
New poster
Posts: 50 Joined: Tue May 25, 2010 9:10 am
Contact:
Post
by shaon_cse_cu08 » Sun Aug 01, 2010 8:29 am
I'll keep holding on...Until the walls come tumbling down...And freedom is all around .....
Trarex
New poster
Posts: 3 Joined: Sun Dec 26, 2010 3:34 am
Post
by Trarex » Sun Dec 26, 2010 3:38 am
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?
Trarex
New poster
Posts: 3 Joined: Sun Dec 26, 2010 3:34 am
Post
by Trarex » Sun Dec 26, 2010 12:10 pm
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;
}
sir. manuel
New poster
Posts: 18 Joined: Sat Nov 20, 2010 7:44 pm
Post
by sir. manuel » Mon Dec 27, 2010 8:49 pm
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!!!
Trarex
New poster
Posts: 3 Joined: Sun Dec 26, 2010 3:34 am
Post
by Trarex » Mon Dec 27, 2010 9:09 pm
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;
}
foo
New poster
Posts: 1 Joined: Thu May 17, 2012 9:44 pm
Post
by foo » Thu May 17, 2012 10:02 pm
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
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Thu May 17, 2012 11:32 pm
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.
Check input and AC output for thousands of problems on
uDebug !
BlâckFoX
New poster
Posts: 1 Joined: Thu Aug 09, 2012 5:17 pm
Post
by BlâckFoX » Thu Aug 09, 2012 5:19 pm
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;
}
brianfry713
Guru
Posts: 5947 Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA
Post
by brianfry713 » Fri Aug 10, 2012 5:58 am
Try printing only the integer portion instead of using round().
Check input and AC output for thousands of problems on
uDebug !