Advertisement
Josif_tepe

Untitled

Jan 27th, 2024
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int M;
  8.     cin >> M;
  9.    
  10.     int ckorcinja[10] = {6, 3, 5, 5, 4, 5, 5, 3, 7, 5};
  11.     for(int i = 9999; i >= 1000; i -= 1) {
  12.         int tmp = i;
  13.         int potrebni_ckorcinja = 0;
  14.         while(tmp > 0) {
  15.             int cifra = tmp % 10;
  16.             potrebni_ckorcinja += ckorcinja[cifra];
  17.             tmp /= 10;
  18.         }
  19.         if(potrebni_ckorcinja == M) {
  20.             cout << i << endl;
  21.             return 0;
  22.         }
  23.     }
  24.     cout << -1 << endl;
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement