fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define con continue
  4. #define bk break
  5. #define LL long long
  6. #define db double
  7. #define pt cout<<'\n'
  8. #define ms(a, b) memset((a), (b), sizeof(a))
  9. #define mp make_pair
  10. #define endl '\n'
  11. int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
  12. #define sz size()
  13. #define len(X) strlen(X)
  14. #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  15. #define ULL unsigned long long
  16. #define de cout<<"test"<<endl;
  17. #define st system("pause");
  18. #define F first
  19. #define S second
  20. #define M_PI 3.1415926
  21. #define ac fstream cin("input.txt");ofstream cout("output.txt");
  22. class CandyMaking
  23. {
  24. public:
  25. double findSuitableDensity(vector <int> A, vector <int> B)
  26. {
  27.  
  28. }
  29. };
  30. int ok=0;
  31. vector<int>ans;
  32. int solve(int now,int g){
  33. if(now>g){
  34. return 0;
  35. }
  36. if(now==g){
  37. ok=1;
  38. return 1;
  39. }
  40. if(!ok)
  41. if(solve(now+4,g)){
  42. ans.push_back(4);
  43. }
  44.  
  45. if(!ok)
  46. if(solve(now+7,g)){
  47. ans.push_back(7);
  48. }
  49.  
  50. }
  51. int main()
  52. {
  53. int a;
  54. while(cin>>a){
  55. solve(0,a);
  56. if(!ok){
  57. cout<<-1<<endl;
  58. }
  59. int n=ans.sz;
  60. cout<<n<<endl;
  61.  
  62. for(int i=n-1;i>=0;i--){
  63. cout<<ans[i];
  64. }
  65. pt;
  66. }
  67. return 0;
  68. }
  69.  
Runtime error #stdin #stdout 0s 15240KB
stdin
11
stdout
Standard output is empty