#include #include #include #include using namespace std; using bigint = unsigned long long int; int check(bigint n) { bigint p = n * 999; int s = 0; while ( p ) { s += p % 1000; p = p / 1000; } return s; } int main(int argc, char* argv[]) { int count = 0; bigint n = 1; int stop; if ( argc == 2 ) { try { stop = stoi(argv[1]); } catch (exception& e) { cerr << "ERROR: '" << argv[1] << "' is not a number" << endl; return 0; } } else { cerr << "Usage: " << argv[0] << " COUNT" << endl; return 0; } while ( count < stop ) { if ( check(n) != 999 ) { cout << n << " * 999 = " << n*999 << " -> " << check(n) << endl; ++count; } ++n; } return 0; }