PAT
PAT copied to clipboard
🍭 浙江大学PAT题解(C/C++/Java/Python) - 努力成为萌萌的程序媛~
提交PAT Advanced Level Problem 1004 "Counting Leaves"的Java解决方案。此问题涉及使用广度优先搜索(BFS)来计算树的每一层的叶子节点数。 新增`Main`类,包括: `createTree`方法用于根据输入数据建立树结构。 `countLeafNodes`方法应用BFS统计每层的叶子节点数。 `printList`方法用于输出结果。 已使用PAT平台的多个测试用例进行验证,确保代码正确处理各种边界情况。
比如说输入以下数据 ```text 4 8:00:00 4 0 8:01:00 3 0 8:02:00 1 0 8:02:01 1 0 2 1 1 ``` 仓库中的代码输出如下: ```text 08:00:00 08:00:00 0 08:01:00 08:01:00 0 08:02:00 08:04:00 2...
``` #include using namespace std; typedef long long ll; int n,w1,w2; int win1[3],win2[3]; int change(char c) { if(c=='B') return 0; else if(c=='C') return 1; else return 2; } int main()...
``` #include #include using namespace std; typedef long long ll; int main() { cin>>n>>m; int a[n]; for(i=0;i>a[i]; for(i=0;i(i+m )%n实现位置的变换,可以逆转换变换后的a[j]=a[i+kn-m] , if(j
## 虽然比仓库里的代码要多几行,但是更加符合PythonIC风格规范 ```python #!/usr/bin/python3.8 # Author: ye_3000 # Created Time: 2022-07-06 n, m = list(map(int, input().split())) ls = list(input().split()) m %= n ls[:] = ls[:: -1] ls[:m] = ls[:m][:: -1]...
在柳神代码上面改,并且增加了详细注释,第82道93行是我新添加的代码,其他都是原样的,望采纳 ``` #include #include #include #include using namespace std; struct person { int arrive, start, time; bool vip; }tempperson; struct tablenode { int end = 8 * 3600, num; bool...