Codeforces Round 946 (Div. 3) A - Phone Desktop 题解
摘要:贪心
传送门:https://www.luogu.com.cn/problem/CF1974A
题意
有一种手机,桌面有若干页,每一页都是
现有
分析思路
考虑贪心。注意到先放
然后统计在这么多页里放下了这些
时间复杂度
代码
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 t, n, m;
inline void solve(void) {
cin >> n >> m;
i64 ans1 = (m + 1) / 2;
i64 rest = ans1 * 7 + (m & 1) * 4;
if (rest >= n) {
cout << ans1 << '\n';
} else {
cout << ans1 + (n - rest + 14) / 15 << '\n';
}
}
inline void optimizeIO(void) {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
}
int main(int argc, char const *argv[]) {
optimizeIO(), cin >> t;
while (t--) solve();
return 0;
}