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