1 #include <bits/stdc++.h> 2 using namespace std; 3 const int N=1e4; 4 int A[N],W[N],num[10]={0,1,2,-1,-1,5,9,-1,8,6}; 5 int change(int x){ 6 int a=x%10;x/=10; 7 int b=x%10;x/=10; 8 int c=x%10;x/=10; 9 int d=x%10;x/=10; 10 a=num[a];if(a==-1)return -1; 11 b=num[b];if(b==-1)return -1; 12 c=num[c];if(c==-1)return -1; 13 d=num[d];if(d==-1)return -1; 14 int ans=a*1000+b*100+c*10+d; 15 if(ans<1000)return -1; 16 return ans; 17 } 18 bool check(int i,int j){ 19 if(W[i]+W[j]!=558)return false; 20 if(W[i]>0)swap(i,j); 21 int a=abs(W[i]),b=W[j]; 22 if(a>200&&a<300&&b>800&&b<900)return true; 23 return false; 24 } 25 int main(){ 26 for(int i=1000;i<N;i++){ 27 A[i]=change(i); 28 if(A[i]!=-1) 29 W[i]=A[i]-i; 30 } 31 for(int i=1000;i<N;i++) 32 for(int j=i+1;j<N;j++) 33 if(check(i,j)){ 34 cout<<j<<endl; 35 return 0;//cout<<i<<" "<<j<<endl; 36 } 37 }