x to the power of x (The 5th Provincial Blue Bridge Cup)

Title x x result is equal to 10, find x

This is a question in the fifth provincial competition of the Blue Bridge Cup in previous years. I used the recursive method k for this problem. What he asked for was approximately six decimal places, so he could get the answer quickly. code show as below:

#include <iostream>
#include <cmath>
using namespace std;
double s=2,num;
int t=0;
void asd(double a,double b)
{
    
    
 if(t>=7)
 return;
 double sum,i;
 for(i=0;i<=9;i++)
 {
    
    
  sum=pow(a+i/(pow(10,t+1)),a+i/(pow(10,t+1)));
  if(sum>10.0)
  {
    
    
   num=i-1;
   s+=num/(pow(10,t+1));
   t++;
		//cout<<t<<":"<<s<<endl;
   asd(s,s);
   return;
  }
 }
}
int main()
{
    
    
 asd(2.0,2.0);
 printf("%.6lf\n",s);
 return 0;
}
输出:2.506184

Guess you like

Origin blog.csdn.net/HT24k/article/details/104963039