1 #include"iostream"
 2 #include"stdio.h"
 3 using namespace std;
 4 typedef long long ll;
 5 
 6 ll f(ll n)
 7 {
 8     ll fn=0,ntemp=n;
 9     ll step;
10     for(step=1;ntemp>0;step*=10,ntemp/=10)
11     {
12         fn+=(((ntemp-1)/10)+1)*step;
13         if((ntemp%10)==1)
14         {
15             fn-=step-(n%step+1);
16         }
17     }
18     return fn;
19 }
20 
21 ll get_max_fn_equal_n(ll upper_bound)
22 
23 {
24     ll n=1,fn=0;
25     ll max=1;
26     while(n<=upper_bound)
27     {
28         fn=f(n);
29         if(fn==n)
30         {
31             max=n;
32             cout<<n++<<endl;
33         }
34         else if(fn<n)
35             n+=(n-fn)/10+1;
36         else
37             n=fn;
38     }
39     return max;
40 }
41 
42 int main()
43 {
44     ll upper_bound=4000000000;
45     cout<<f(13)<<endl;
46     cout<<get_max_fn_equal_n(upper_bound);
47     return 0;
48 }
View Code

相关文章:

  • 2021-10-03
  • 2021-06-07
  • 2022-12-23
  • 2021-05-02
  • 2021-05-22
  • 2021-05-27
猜你喜欢
  • 2021-07-05
  • 2021-08-13
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案