Codeforces Round #634 (Div. 3) 比赛人数11922 慢慢的对Div. 3难度有了些感觉
[codeforces 1335A] Candies and Two Sisters 注意n是奇偶的情况
总目录详见https://blog.youkuaiyun.com/mrcrack/article/details/103564004
在线测评地址https://codeforces.com/contest/1335/problem/A
| Problem | Lang | Verdict | Time | Memory |
|---|---|---|---|---|
| A - Candies and Two Sisters | GNU C++17 | Accepted | 31 ms | 0 KB |
手工算法如下
n=6
a=5,b=1;
a=4,b=2;
共2种可能
n=7
a=6,b=1;
a=5,b=2;
a=4,b=3;
共3种可能
AC代码如下
#include <stdio.h>
int main(){
int t,n;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
if(n<=2)printf("0\n");//特判
else printf("%d\n",(n-1)/2);
}
return 0;
}
本文详细解析了Codeforces Round #634 (Div.3) 中的问题Candies and Two Sisters,展示了如何通过算法解决糖果分配问题,并提供了AC代码实现。对于初学者理解Div.3难度的比赛很有帮助。
646

被折叠的 条评论
为什么被折叠?



