Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int M;
- cin >> M;
- int ckorcinja[10];
- ckorcinja[0] = 6;
- ckorcinja[1] = 3;
- ckorcinja[2] = 5;
- ckorcinja[3] = 5;
- ckorcinja[4] = 4;
- ckorcinja[5] = 5;
- ckorcinja[6] = 5;
- ckorcinja[7] = 3;
- ckorcinja[8] = 7;
- ckorcinja[9] = 5;
- for(int i = 9999; i >= 1000; i--) {
- int broj = i;
- int potrebni_ckorcinja = 0;
- while(broj > 0) {
- int posledna_cifra = broj % 10;
- broj /= 10;
- potrebni_ckorcinja += ckorcinja[posledna_cifra];
- }
- if(potrebni_ckorcinja == M) {
- cout << i << endl;
- return 0;
- }
- }
- cout << -1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement