_takumi

num22.2

Nov 25th, 2020
491
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int F(int x) {
  5.     int a = 0, b = 10, c;
  6.     while (x>0) {
  7.         c = x % 10;
  8.         a = a + c;
  9.         if (c < b)
  10.             b = c;
  11.         x = x /10;
  12.     }
  13.     return a * 10 + b;
  14. }
  15.  
  16. int main() {
  17.     for (int w = 0; w < 1000; w++) {
  18.         if (F(w) == 156) {
  19.             cout << w;
  20.             break;
  21.         }
  22.     }
  23.     return 0;
  24. }
RAW Paste Data