NC223616. HRemainderReminder
描述
输入描述
Input consists of seven positive integers a b c d e f g, where a and b (a ≤ b, 7 ≤ a, b ≤ 100) are the dimensions of the sheets of cardboard (in inches), c, d and e (1 ≤ c, d, e ≤ 109 ) are the number of books left over for the three largest size boxes possible for the given size cardboard sheets (in order from largest box size to third largest box size) and f and g specify an inclusive range for the number of books (1 ≤ f < g ≤ 109 ).
输出描述
Output the number of books which satisfy all the conditions of the problem. Each problem is guaranteed to have a unique answer
示例1
输入:
16 21 407 409 17 20000 30000
输出:
22457
C++ 解法, 执行用时: 6ms, 内存消耗: 432K, 提交时间: 2022-01-28 01:17:43
#include<bits/stdc++.h> using namespace std; int a, b, c, d, e, f, g, v[88], ans; int main() { cin >> a >> b >> c >> d >> e >> f >> g; for(int i = 1; i <= a/2; i++) v[i] = (a-2*i) * (b-2*i) * i; sort(v, v+55); for(ans = c; ans <= g; ans += v[54]) if(ans >= f && ans % v[53] == d && ans % v[52] == e) return cout << ans, 0; }