Page 9 of 11

Posted: Sat Oct 21, 2006 11:03 pm
by Salehwar
Try this out.. it worked with me:

Code: Select all

cout<<setiosflags(ios::fixed)<<setprecision(0)<<pow(p, 1.0/n)<<endl;
Also this way works too:

Code: Select all

k = pow(p, 1.0/n); printf("%.0lf\n",k); 

With both ways n, p, k are defined as double. Let know if it worked with you.



Edit: Edited the codes.. forgot something to mention.

113 Somebody can Help me? WA

Posted: Wed Jan 03, 2007 2:51 am
by Saul Hidalgo
I did send the exercise 113 and i dont know why.
Here is the code...

Code: Select all

#include <iostream>
#include <cmath>

using namespace std;

int main(){
    double k,p,temp;
    while(cin>>k>>p){
        temp=(1.0)/k;
        cout << floor(pow(p,temp))<<endl;
    }
    return 0;
}
And i too submit is code, but i had been WA.

Code: Select all

#include <iostream>
#include <cmath>

using namespace std;

int main(){
    double k,p,temp;
    while(cin>>k>>p){
        temp=(1.0)/k;
        cout << pow(p,temp)<<endl;
    }
    return 0;
}
Thanks.

Posted: Wed Jan 03, 2007 6:09 am
by rickyliu
Your program cannot solve the last case of the sample input. Consider using log.

Posted: Wed Jan 03, 2007 6:22 am
by emotional blind
Try again using

Code: Select all

	cout.setf(ios::fixed); 
	cout.precision(0); 
at very beginning of main function

113, WA (beginner)

Posted: Sun Jan 07, 2007 4:28 pm
by sathyashrayan
Dear group,
My code is wrong, I know that very well. The code just simply hangs.. Can any one help.. Thnaks..

Code: Select all


#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void)
{
	 long long k,                
			 n,          
			   result,   
			   p;      
					   
    unsigned int       i;      
    					
    						
      i = pow(10,101);          			
      
      /*Give p and n we need to find k, which is the n pow k */
    						        
	     scanf("%lld %lld",&n,&p);
	     for(k =1 ; k < pow(10,9); k ++)
	     {
		     result = pow(n,k);
		     if(result == p)
		     {
			     printf("%lld\n",k);
			     	     		  
     		 }
     	
     		 if(p > i)
	     		    exit(0);	 
 	     }
 	     
		
	return 0;
}

Posted: Sun Jan 14, 2007 6:52 am
by vijay03
Since the nos are very large here, it is sufficient to take the root and store it in a long double. Just do the following:

1. You need to keep taking input as long as the judge keeps giving them. For that, use

Code: Select all


  while(scanf("%lf %lf",&n,&p)==2)
  {

   // the processing of each pair of input
  }

2. Inside the while loop, simply calculate p to the power 1.0/n, floor the result and print with "%0.lf\n"

Hope this helps

Posted: Wed Jan 17, 2007 5:13 pm
by Debashis Maitra
I thing double is enough to solve this problem

113:

Posted: Thu Jul 05, 2007 6:07 am
by lnr

Code: Select all


Thanks stubbscroll
GOT AC. 


Posted: Thu Jul 05, 2007 3:44 pm
by stubbscroll
Change long double to double and don't forget to remove your code if it works.

Posted: Mon Jul 09, 2007 1:54 am
by smilitude
god! this is a frightening bad problem! i remember that i was very frustrated with this one! :(

Posted: Thu Jan 31, 2008 1:13 am
by Saul Hidalgo
Good. Thanks. I got AC :wink: :wink:

Re: 113- power of cryptography T\E

Posted: Sun Oct 25, 2009 7:54 am
by noor_aub
I have got acc before. But now I get T/E. Why

Code: Select all

Removed After A/C

Re: 113- power of cryptography - What is the algorithm?

Posted: Thu Oct 29, 2009 1:27 am
by fahim_xubayer
@ noor vai

have a look at the way you are taking the input :) it should be while(scanf("%lf %lf",&b,&a)==2) :)
hope this kids advice helps LOL :)

Re: 113- power of cryptography - What is the algorithm?

Posted: Wed Nov 04, 2009 9:39 am
by noor_aub
Thanks
:P

113 whats my problem? please help me

Posted: Thu Jul 22, 2010 1:09 pm
by @mjad

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;
}