Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- int s;
- cin>>s;
- int l=1;
- int a,b,c,d;
- int k[10];
- k[0]=6;
- k[1]=3;
- k[2]=5;
- k[3]=5;
- k[4]=4;
- k[5]=5;
- k[6]=5;
- k[7]=3;
- k[8]=7;
- k[9]=5;
- for(n=9999;n>=1000;n--)
- {
- d=n%10;
- c=(n/10)%10;
- b=(n/100)%10;
- a=(n/1000)%10;
- if((k[a]+k[b]+k[c]+k[d])==s)
- {
- l=0;
- break;
- }
- }
- if(l==1)
- {
- cout<<-1;
- }else
- cout<<n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement