fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 5000; int dp[ 2 ][ N ];
  6.  
  7. int sum_of_digits( int x )
  8. {
  9. int z = 0;
  10.  
  11. for( auto c: to_string( x ) )
  12. z += c - '0';
  13.  
  14. return z;
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20. ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
  21.  
  22. for( int x = 0, y = 0; x < N; x++, y += 2 )
  23. dp[ 0 ][ x ] = sum_of_digits( x ),
  24. dp[ 1 ][ x ] = sum_of_digits( y );
  25.  
  26. for( int x1 = 0; x1 < N; x1++ )
  27. for( int s1 = 50 - dp[ 0 ][ x1 ], t1 = 55 - dp[ 1 ][ x1 ], x2 = x1; x2 < N; x2++ )
  28. if ( dp[ 0 ][ x2 ] == s1 and dp[ 1 ][ x2 ] == t1 )
  29. {
  30. cout << x1 << x2 << x1 << x2; return 0;
  31. }
  32. }
Success #stdin #stdout 0s 15272KB
stdin
Standard input is empty
stdout
19949991994999