Algorithm


Problem Name: beecrowd | 1933

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1933

Tri-du

 

By Ricardo Anido, Universidade Estadual de Campinas BR Brazil

Timelimit: 1

Tri-du is a card game inspired in the popular game of Truco. The game uses a normal deck of 52 cards, with 13 cards of each suit, but suits are ignored. What is used is the value of the cards, considered as integers between 1 to 13.

In the game, each player gets three cards. The rules are simple:

 

  • A Three of a Kind (three cards of the same value) wins over a Pair (two cards of the same value).
  • A Three of a Kind formed by cards of a larger value wins over a Three of a Kind formed by cards of a smaller value.
  • A Pair formed by cards of a larger value wins over a Pair formed by cards of a smaller value.

Note that the game may not have a winner in many situations; in those cases, the cards are returned to the deck, which is re-shuffled and a new game starts.

A player received already two of the three cards, and knows their values. Your task is to write a program to determine the value of the third card that maximizes the probability of that player winning the game.

 

Input

 

The input consists of a single line, which contains two integers A (1 ≤ A ≤ 13) and B (1 ≤ B ≤ 13) that indicates the value of the two first received cards.

 

Output

 

Your program must produce a single line, containing exactly one integer, representing the value of the card that maximizes the probability of the player winning the game.

 

 

 

Input Example Output Example

10 7

10

 

2 2

2

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<string>
#include<list>
#include<string.h>

using namespace std;

#define ll long long
#define MAX 999999999999999999
#define MIN 0
#define PI acos(-1)
#define E 2.718281828459
#define ii pair < int, int>

int main(int argc, char** argv) {
	//freopen("c.txt","w",stdout);
	int A,B;
	while(cin >> A >> B)
	{
		if(A == B)cout << A << endl;
		else{
			cout << max(A,B) << endl;
		}
	}
	return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 7

Output

x
+
cmd
10

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const [arroz, beijinho] = lines.shift().trim().split(" ");

if(arroz == beijinho){
    console.log(arroz);
}
else{
    parseInt(arroz) > parseInt(beijinho) ? console.log(arroz) : console.log(beijinho);
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10 7

Output

x
+
cmd
10
Advertisements

Demonstration


Previous
#1930 Beecrowd Online Judge Solution 1930 Electrical Outlet Solution in C++, Java, Js and Python
Next
#1936 Beecrowd Online Judge Solution 1936 Factorial Solution in C, C++, Java, Js and Python