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;
- for(int i = 9999; i >= 1000; i -= 1) {
- int tmp = i;
- int potrebni_ckorcinja = 0;
- while(tmp > 0) {
- int cifra = tmp % 10;
- if(cifra == 0) {
- potrebni_ckorcinja += 6;
- }
- else if(cifra == 1) {
- potrebni_ckorcinja += 3;
- }
- else if(cifra == 2) {
- potrebni_ckorcinja += 5;
- }
- else if(cifra == 3) {
- potrebni_ckorcinja += 5;
- }
- else if(cifra == 4) {
- potrebni_ckorcinja += 4;
- }
- else if(cifra == 5) {
- potrebni_ckorcinja += 5;
- }
- else if(cifra == 6) {
- potrebni_ckorcinja += 5;
- }
- else if(cifra == 7) {
- potrebni_ckorcinja += 3;
- }
- else if(cifra == 8) {
- potrebni_ckorcinja += 7;
- }
- else if(cifra == 9) {
- potrebni_ckorcinja += 5;
- }
- tmp /= 10;
- }
- if(potrebni_ckorcinja == M) {
- cout << i << endl;
- return 0;
- }
- }
- cout << -1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement