行业知识
2024牛客寒假算法基础集训营4 题解( A,B,C,D,G )
2024牛客寒假算法基础集训营4
A 柠檬可乐
题意
���据给定的 a a a 和 b b b,判断是否 a ≥ k × b a \ge k \times b a≥k×b
思路
题意非常直接
()代码
/*******************************| Author: AlwaysBeShine| Problem: 柠檬可乐| Contest: NowCoder| URL: https://ac.nowcoder.com/acm/contest/67744/A| When: 2024-02-19 13:08:06| | Memory: 524288 MB| Time: 2000 ms*******************************/#include using namespace std;typedef long long ll;int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int a,b,k;cin >> a >> b >> k;if(a >= k*b)cout 1 x \gt 1 x>1的一堆,否则就输了,最后游戏结束的局面肯定是每一堆石子都只有 1 1 1 个。所以对这堆石子操作的最优策略肯定是将其分为 x − 1 x-1 x−1个石子 和 1 1 1 个石子 的两堆。
所以只要判断 个数不为 1 1 1 的 石子堆的个数和他们石子总数的奇偶性即可
奇数就是 sweet 赢,偶数就是 gui 赢
代码
/*******************************| Author: AlwaysBeShine| Problem: 左右互博| Contest: NowCoder| URL: https://ac.nowcoder.com/acm/contest/67744/B| When: 2024-02-19 13:09:33| | Memory: 524288 MB| Time: 2000 ms*******************************/#include using namespace std;typedef long long ll;int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int n;cin >> n;ll sum = 0;int cnt = 0;std::vector a(n);for(int i = 0;i > a[i];if(a[i] != 1){cnt++;sum+=a[i];}}if((sum - cnt) % 2 == 0)cout n >> m >> x >> y;for(int y = 0;y > zf[y][x];}}int p,q;cin >> p >> q;vectorcz(q);for(auto &[op,z]:cz){cin >> op >> z;}while(p--){for(auto &[op,z]:cz){if(op == 1){char tp = zf[z-1][m-1];for(int i = m-2;i >= 0;i--){zf[z-1][i+1] = zf[z-1][i];}zf[z-1][0] = tp;}else{char tp = zf[n-1][z-1];for(int i = n-2;i >= 0;i--){zf[i+1][z-1] = zf[i][z-1];}zf[0][z-1] = tp;}}// for(int y = 0;y > m;for(int y = 1;y jz[x][y];if(jz[x][y] == '.'){qzh[x][y] = 0;qzh1[x][y] = 0;qzh2[x][y] = 0;}else{qzh[x][y] = qzh1[x][y] = qzh2[x][y] = 1;qzh[x][y] += qzh[x-1][y];qzh1[x][y] += qzh1[x+1][y-1];qzh2[x][y] += qzh2[x-1][y-1];}}}if(n > 1 >= size)cnt++;}}}}cout
上一篇:毁坏服务器事件怎么处理?