Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. typedef long double LD;
  5. typedef pair<LL,LL> PLL;
  6. typedef pair<LD,LD> PDD;
  7. typedef pair<int,int> PII;
  8. typedef pair<PII,PII> PPII;
  9. #define B_E(a) a.begin(), a.end()
  10. #define PB push_back
  11. #define MP make_pair
  12. #define S second
  13. #define F first
  14. inline void file() {
  15.     #ifdef _WIN32
  16.         srand(time(NULL));
  17.         return;
  18.     #endif
  19.  
  20.     ios_base::sync_with_stdio(false);
  21.     cin.tie(NULL);
  22.     cout.tie(NULL);
  23.  
  24.     if (1) {
  25.         freopen("ribbon.in",  "r", stdin);
  26.         freopen("ribbon.out", "w", stdout);
  27.     }
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34. const clock_t MAXT = (100*CLOCKS_PER_SEC)/1000;
  35. const int   PX[8] = {1,0,-1,0,  1,1,-1,-1},
  36.             PY[8] = {0,1,0,-1,  -1,1,1,-1},
  37.             N = 2e3 + 10,
  38.             INF = 1e9,
  39.             MOD = 1e9 + 7;
  40. const LL    INFL = 1e18,
  41.             MODL = 1e9 + 7;
  42. const LD    EPS = 1e-9;
  43.  
  44.  
  45. inline int rnd(int l = 0, int r = INF) {
  46.     unsigned ans = rand();
  47.     ans = (ans<<8) ^ rand();
  48.     ans = (ans<<8) ^ rand();
  49.     ans = (ans<<8) ^ rand();
  50.     ans %= r-l+1;
  51.     return int(ans + l);
  52. }
  53.  
  54.  
  55.  
  56. int n,a,b,c,res;
  57.  
  58.  
  59.  
  60.  
  61. main()
  62. { file();
  63.  
  64.     cin>>n>>a>>b>>c;
  65.     res = 1;
  66.  
  67.     for (int x=0; x*a<=n; ++x)
  68.     for (int y=0; y*b+x*a<=n; ++y) {
  69.         int z = n - x*a - y*b;
  70.  
  71.         /// x,y,z - коэфициенты, которые определяют вхождение
  72.         /// каждой части строчки в итоговую
  73.         if ( !(z%c) ) {
  74.             z /= c;
  75.  
  76.                 /// x*a + y*b + z*c == n
  77.             if ( res < x+y+z )
  78.                 res = x+y+z;
  79.         }
  80.     }
  81.  
  82.     cout<<res;
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement