PAT b1046-b1049题解
来源:互联网 发布:如何评价地狱边境 知乎 编辑:程序博客网 时间:2024/05/22 06:30
1、b1046
#include <cstdio>int main(){int ha = 0, hb = 0;int n;scanf("%d", &n);while(n--){int a1, a2, b1, b2;scanf("%d%d%d%d", &a1, &a2, &b1, &b2);if(a1 + b1 == a2 && a1 + b1 != b2){hb++;}else if(a1 + b1 == b2 && a1 + b1 != a2){ha++;}}printf("%d %d", ha, hb);}
2、b1047
#include <cstdio>const int maxn = 1010;int hashTable[maxn] = {0};int main(){int n;scanf("%d", &n);for(int i = 0; i < n; i++){int team, member, score;scanf("%d-%d %d", &team, &member, &score);hashTable[team] += score;}int k, max = -1;for(int i = 0; i < maxn; i++){if(hashTable[i] > max){k = i;max = hashTable[i];}}printf("%d %d\n", k, max);return 0;}
3、b1048
#include <cstdio>#include <cstring>const int maxn = 110;char A[maxn], B[maxn], ans[maxn] = {0};void reverse(char s[]){int len = strlen(s);for(int i = 0; i < len / 2; i++){int temp = s[i];s[i] = s[len - 1 - i];s[len - 1 - i] = temp;}}int main(){scanf("%s %s", A, B);reverse(A);reverse(B);int lenA = strlen(A);int lenB = strlen(B);int len = lenA > lenB ? lenA : lenB;for(int i = 0; i < len; i++){int numA = i < lenA ? A[i] - '0' : 0;int numB = i < lenB ? B[i] - '0' : 0;if(i % 2 == 0){int temp = (numB + numA) % 13;if(temp == 10){ans[i] = 'J';}else if(temp == 11){ans[i] = 'Q';}else if(temp == 12){ans[i] = 'K';}else{ans[i] = temp + '0';}}else{int temp = numB - numA;if(temp < 0){temp += 10;}ans[i] = temp + '0';}}reverse(ans);puts(ans);return 0;}
4、b1049
#include <cstdio>int main(){int n;double v, ans = 0;scanf("%d", &n);for(int i = 1; i <= n; i++){scanf("%lf", &v);ans += v * i * (n + 1 -i);}printf("%.2f\n", ans);return 0;}
阅读全文
1 0
- PAT b1046-b1049题解
- PAT B1049
- PAT B1046
- 浙大 PAT b1049
- 浙大 PAT b1046
- PAT B1046. 划拳(15)
- PAT:B1046. 划拳(15)
- PAT乙级练习题B1046. 划拳
- PAT-B1049. 数列的片段和
- PAT乙级练习题B1049. 数列的片段和
- B1046.划拳
- PAT 1001-1010 题解
- PAT 1011-1020 题解
- PAT 1021-1030 题解
- PAT 1031-1040 题解
- PAT 1041-1050 题解
- PAT 1051-1060 题解
- PAT(basic level)题解
- 插入排序-算法
- LeetCode--Regular Expression Matching
- NP-complete problems课后题
- rpm 安装软件
- 从Hermite插值公式推导Smoothstep插值公式
- PAT b1046-b1049题解
- 【网络】URG 和 PSH 标志位
- Js(四)随笔(个人观看)
- Nginx负载均衡NFS配置
- C++ sizeof操作符
- 嵌入式每日学习心得2017.07.13
- underscore.js 102 -- 170行
- PAT a1001题解
- 网络配置,内网无法访问外网