关于C题的分讨
在本人大力分讨过后还是一直WA,但是不知道为什么WA,有无大佬指出哪里出问题了Orz
/* * @Author: Aisaka_Taiga * @Date: 2023-11-03 19:45:08 * @LastEditTime: 2023-11-03 21:35:15 * @LastEditors: Aisaka_Taiga * @FilePath: \Desktop\T3.cpp * The heart is higher than the sky, and life is thinner than paper. */ #include <bits/stdc++.h> #define int long long #define N 200100 using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while(c < '0' || c > '9'){if(c == '-') f = -1; c = getchar();} while(c <= '9' && c >= '0') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return x * f; } int n, m, k, a[N], sum, cnt; inline void work() { int ans = 0; n = read(), m = read(), k = read(); if(k == 1) return cout << m << endl, void(); if(k % 2 == 0) { int kk = n % k; if(kk % 2 == 1) ans ++, kk --; if(m >= kk / 2) ans += (m - kk / 2) % (k / 2); else ans += m; cout << ans << endl; return ; } int xx = k / 2;//一团最多多少女的 int kk = m / xx;//几团 int cc = m - kk * xx;//多余的女的 if(n >= kk) { n -= kk;//还有多少男的没成团 if(n + cc * 2 < k) return cout << n + cc << endl, void(); n -= (k - cc * 2); n %= k; if(n / 2 <= m) return cout << (n + 1) / 2 << endl, void(); cout << n - m << endl; return ; } cout << (kk - n) * xx + cc << endl; return ; } signed main() { int T = read(); while(T --) work(); return 0; } /* 2 1 1 4 4 5 2 */