Codeforces Round #592 (Div. 2)

Contest Info


[Practice Link](https://codeforces.com/contest/1244)
Solved A B C D E F G
7/7 O O Ø Ø Ø Ø Ø
  • O 在比赛中通过
  • Ø 赛后通过
  • ! 尝试了但是失败了
  • - 没有尝试

Solutions


A. Pens and Pencils

签到。

B. Rooms and Staircases

签到。

C. The Football Season

题意:
给出(n, p, w, d),求解:

[egin{eqnarray*} x cdot w + y cdot d = p \ x + y leq n end{eqnarray*} ]

题目保证(d < w)

思路:
题目保证了(d < w),那么有(y < w),因为如果(y = w),那么相当于(w * d),然后取了(w)(d),那么不如取(d)(w)更优。
所以直接暴力即可。
也可以直接上(exgcd),但是要讨论的东西挺多的。

代码:

view code
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define fi first
#define se second
#define endl "
" 
using namespace std;
using db = double;
using ll = long long;
using ull = unsigned long long; 
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; while (x >= mod) x -= mod; while (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }  
#define dbg(x...) do { cout << "