见:https://blog.csdn.net/dormousenone/article/details/75208903
1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa system("cls") 4 #include <iostream>//pair 5 #include <fstream>//freopen("C:\\Users\\13606\\Desktop\\草稿.txt","r",stdin); 6 #include <bitset> 7 //#include <map> 8 //#include<unordered_map> 9 #include <vector> 10 #include <stack> 11 #include <set> 12 #include <string.h>//strstr substr 13 #include <string> 14 #include <time.h>//srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9; 15 #include <cmath> 16 #include <deque> 17 #include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less 18 #include <vector>//emplace_back 19 //#include <math.h> 20 //#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor 21 #include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare) 22 using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation 23 #define fo(a,b,c) for(register int a=b;a<=c;++a) 24 #define fr(a,b,c) for(register int a=b;a>=c;--a) 25 #define mem(a,b) memset(a,b,sizeof(a)) 26 #define pr printf 27 #define sc scanf 28 #define ls rt<<1 29 #define rs rt<<1|1 30 typedef long long ll; 31 #define rint register int; 32 void swapp(int &a,int &b); 33 double fabss(double a); 34 int maxx(int a,int b); 35 int minn(int a,int b); 36 int Del_bit_1(int n); 37 int lowbit(int n); 38 int abss(int a); 39 //const long long INF=(1LL<<60); 40 const double E=2.718281828; 41 const double PI=acos(-1.0); 42 const int inf=(1<<30); 43 const double ESP=1e-9; 44 const int mod=(int)1e9+7; 45 const int N=(int)1e6+10; 46 47 ll ans[100]; 48 char s[N]; 49 ll get(int l) 50 { 51 ll sum=0; 52 for(int i=1;i<=l;++i) 53 sum*=10,sum+=s[i]-'0'; 54 return sum; 55 } 56 57 int main() 58 { 59 ans[1]=1; 60 ans[2]=199981; 61 ans[3]=199982; 62 ans[4]=199983; 63 ans[5]=199984; 64 ans[6]=199985; 65 ans[7]=199986; 66 ans[8]=199987; 67 ans[9]=199988; 68 ans[10]=199989; 69 ans[11]=199990; 70 ans[12]=200000; 71 ans[13]=200001; 72 ans[14]=1599981; 73 ans[15]=1599982; 74 ans[16]=1599983; 75 ans[17]=1599984; 76 ans[18]=1599985; 77 ans[19]=1599986; 78 ans[20]=1599987; 79 ans[21]=1599988; 80 ans[22]=1599989; 81 ans[23]=1599990; 82 ans[24]=2600000; 83 ans[25]=2600001; 84 ans[26]=13199998; 85 ans[27]=35000000; 86 ans[28]=35000001; 87 ans[29]=35199981; 88 ans[30]=35199982; 89 ans[31]=35199983; 90 ans[32]=35199984; 91 ans[33]=35199985; 92 ans[34]=35199986; 93 ans[35]=35199987; 94 ans[36]=35199988; 95 ans[37]=35199989; 96 ans[38]=35199990; 97 ans[39]=35200000; 98 ans[40]=35200001; 99 ans[41]=117463825; 100 ans[42]=500000000; 101 ans[43]=500000001; 102 ans[44]=500199981; 103 ans[45]=500199982; 104 ans[46]=500199983; 105 ans[47]=500199984; 106 ans[48]=500199985; 107 ans[49]=500199986; 108 ans[50]=500199987; 109 ans[51]=500199988; 110 ans[52]=500199989; 111 ans[53]=500199990; 112 ans[54]=500200000; 113 ans[55]=500200001; 114 ans[56]=501599981; 115 ans[57]=501599982; 116 ans[58]=501599983; 117 ans[59]=501599984; 118 ans[60]=501599985; 119 ans[61]=501599986; 120 ans[62]=501599987; 121 ans[63]=501599988; 122 ans[64]=501599989; 123 ans[65]=501599990; 124 ans[66]=502600000; 125 ans[67]=502600001; 126 ans[68]=513199998; 127 ans[69]=535000000; 128 ans[70]=535000001; 129 ans[71]=535199981; 130 ans[72]=535199982; 131 ans[73]=535199983; 132 ans[74]=535199984; 133 ans[75]=535199985; 134 ans[76]=535199986; 135 ans[77]=535199987; 136 ans[78]=535199988; 137 ans[79]=535199989; 138 ans[80]=535199990; 139 ans[81]=535200000; 140 ans[82]=535200001; 141 ans[83]=1111111110; 142 while(~sc("%s",s+1)) 143 { 144 int l=strlen(s+1); 145 if(l>13) 146 pr("83 1111111110\n"); 147 else 148 { 149 ll t=get(l); 150 for(int i=1;i<=83;++i) 151 { 152 if(i==83||t<ans[i+1]) 153 { 154 pr("%d %lld\n",i,ans[i]); 155 break; 156 } 157 } 158 } 159 } 160 return 0; 161 } 162 163 /**************************************************************************************/ 164 165 int maxx(int a,int b) 166 { 167 return a>b?a:b; 168 } 169 170 void swapp(int &a,int &b) 171 { 172 a^=b^=a^=b; 173 } 174 175 int lowbit(int n) 176 { 177 return n&(-n); 178 } 179 180 int Del_bit_1(int n) 181 { 182 return n&(n-1); 183 } 184 185 int abss(int a) 186 { 187 return a>0?a:-a; 188 } 189 190 double fabss(double a) 191 { 192 return a>0?a:-a; 193 } 194 195 int minn(int a,int b) 196 { 197 return a<b?a:b; 198 }