其实是一道大水题,但是自己写的时候一开始居然没想到去枚举k就可以了,确实不擅长做数学题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 #include <bits/stdc++.h> #define int long long #define ull unsigned long long #define mmst0(x) memset(x,0,sizeof(x)) using namespace std ;const int INF=0x3f3f3f3f ;int read () {char c;int num,f=1 ;while (c=(char )getchar(),!isdigit (c))if (c=='-' )f=-1 ;num=(int )(c-'0' );while (c=(char )getchar(),isdigit (c))num=num*10 +(int )(c-'0' );return num*f;}void prt (int x) {if (x<0 ){putchar ('-' );x=-x;}if (x>9 )prt(x/10 );putchar ((char )(x%10 +'0' ));}int n,a,b,c;int t[10000 ];void work () { while (n=read()) { int cnt=0 ; for (int k=1 ;k<=n;k*=10 ) { c=(n/k)/11 ; b=n/k-c*11 ; if ((b!=0 || c!=0 ) && b<10 ) { a=(n-b*k-11 *c*k)/2 ; if (2 *a+b*k+11 *c*k==n) t[++cnt]=a+b*k+c*k*10 ; } b--; if ((b!=0 || c!=0 ) && b>=0 ) { a=(n-b*k-11 *c*k)/2 ; if (2 *a+b*k+11 *c*k==n) t[++cnt]=a+b*k+c*k*10 ; } } if (!cnt) { printf ("No solution.\n" ); } else { sort(t+1 ,t+1 +cnt,[](int a,int b){ return a<b; }); printf ("%d" ,t[1 ]); for (int i=2 ;i<=cnt;i++) if (t[i]!=t[i-1 ]) printf (" %d" ,t[i]); printf ("\n" ); } } return ; } signed main () { int T=1 ; for (int Case=1 ;Case<=T;Case++) { work(); } return 0 ; }