Kattis - bela
Bela
Young Mirko is a smart, but mischievous boy who often wanders around parks looking for new ideas. This time he’s come across pensioners playing the card game Belote. They’ve invited him to help them determine the total number of points in a game.
Each card can be uniquely determined by its number and suit. A set of four cards is called a hand. At the beginning of a game one suit that “trumps” any other is chosen, and it is called the dominant suit. The number of points in a game is equal to the sum of values of each card from each hand in the game. Mirko has noticed that the pensioners have played?NN?hands and that suit?BB?was the dominant suit.
The value of each card depends on its number and whether its suit is dominant, and is given in Table?1.
| Number | Value | |
| ? | Dominant | Not dominant |
| A | 1111 | 1111 |
| K | 44 | 44 |
| Q | 33 | 33 |
| J | 2020 | 22 |
| T | 1010 | 1010 |
| 9 | 1414 | 00 |
| 8 | 00 | 00 |
| 7 | 00 | 00 |
Write a programme that will determine and output the number of points in the game.
?Input
The first line contains the number of hands?NN?(1≤N≤1001≤N≤100) and the value of suit?BB?(S,?H,?D,?C) from the task. Each of the following?4N4N?lines contains the description of a card (the first character is the number of the?ii-th card (A,?K,?Q,?J,?T,?9,?8,?7), and the second is the suit (S,?H,?D,?C)).
Output
The first and only line of output must contain the number of points from the task.
| 2 S TH 9C KS QS JS TD AD JH | 60 |
| 4 H AH KH QH JH TH 9H 8H 7H AS KS QS JS TS 9S 8S 7S | ? |
題意
給出一個n和一個b,b是鉆石牌,然后給4*n的卡牌,計算總積分,如果有b的話則加上面對應的表的第一個數,否則加第二個數
代碼
#include<bits/stdc++.h> using namespace std; struct Node {int a1;int a2; } aa[200];int main() {int n;char b;cin >> n >> b;int sum = 0;aa[65].a1 = 11;aa[65].a2 = 11;aa[75].a1 = 4;aa[75].a2 = 4;aa[81].a1 = 3;aa[81].a2 = 3;aa[74].a1 = 20;aa[74].a2 = 2;aa[84].a1 = 10;aa[84].a2 = 10;aa[57].a1 = 14;aa[57].a2 = 0;aa[56].a1 = 0;aa[56].a2 = 0;aa[55].a1 = 0;aa[55].a2 = 0;for(int i = 0; i < 4 * n; i++) {char b1, b2;cin >> b1 >> b2;if(b2 == b) {sum += aa[b1].a1;} elsesum += aa[b1].a2;}cout << sum << endl;return 0; }?
?
轉載于:https://www.cnblogs.com/zhien-aa/p/6279553.html
總結
以上是生活随笔為你收集整理的Kattis - bela的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Javaweb 第15天 web练习和
- 下一篇: 使用 Rx 中预定义的 Subject