A.小红不想做炸鸡块粉丝粉丝题
Code:
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int v, s = 0; cin >> v; s += v; for (int i = 1, x; i <= 4; i++) { cin >> x; s += x; } cout << (v * 30 < s ? "Yes\n" : "No\n"); return 0; }
B.小红不想做鸽巢原理
Code:
#include<bits/stdc++.h> using namespace std; typedef long long i64; const int N = 1e5 + 5; int a[N]; i64 sum = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k, i = 0; cin >> n >> k; for (i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } sum %= k; if (!sum) return cout << "0\n", 0; sort(a + 1, a + n + 1); int ans = 0; for (int i = n; i >= 1; i--) { if (!sum) break; sum = max(0LL, sum - a[i]); ans ++; } cout << ans << '\n'; return 0; }
标签:周赛,39,false,cout,int,sum,虐记,cin,tie From: https://www.cnblogs.com/youhualiuh/p/18120175