1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
PolarNik [594]
3 years ago
6

In the simulation, player 2 will always play according to the same strategy. The number of coins player 2 spends is based on wha

t round it is, as described below. (a) You will write method getPlayer2Move, which returns the number of coins that player 2 will spend in a given round of the game. In the first round of the game, the parameter round has the value 1, in the second round of the game, it has the value 2, and so on. The method returns 1, 2, or 3 based on the following rules. If round is divisible by 3, then return 3. If round is not divisible by 3 but is divisible by 2, then return 2. If round is not divisible by 3 and is not divisible by 2, then return 1. Complete method getPlayer2Move below by assigning the correct value to result to be returned.
Computers and Technology
1 answer:
baherus [9]3 years ago
8 0

The simulation, player 2 will always play according to the same strategy.

Method getPlayer2Move below is completed by assigning the correct value to result to be returned.

Explanation:

  • You will write method getPlayer2Move, which returns the number of coins that player 2 will spend in a given round of the game. In the first round of the game, the parameter round has the value 1, in the second round of the game, it has the value 2, and so on.

#include <bits/stdc++.h>  

using namespace std;

bool getplayer2move(int x, int y, int n)  

{

   int dp[n + 1];  

   dp[0] = false;  

   dp[1] = true;  

   for (int i = 2; i <= n; i++) {  

       if (i - 1 >= 0 and !dp[i - 1])  

           dp[i] = true;  

       else if (i - x >= 0 and !dp[i - x])  

           dp[i] = true;  

       else if (i - y >= 0 and !dp[i - y])  

           dp[i] = true;  

       else

           dp[i] = false;  

   }  

   return dp[n];  

}  

int main()  

{  

   int x = 3, y = 4, n = 5;  

   if (findWinner(x, y, n))  

       cout << 'A';  

   else

       cout << 'B';  

   return 0;  

}

You might be interested in
What is the output of the following program?
Minchanka [31]

Answer:

the answer is t

Explanation:

7 0
3 years ago
Used prevalently on the web, it allows for secure messages to be sent between parties without having to agree on, or share, a se
Sati [7]

Answer: A- Public Key Encryption

Explanation: The Public key Encryption is used prevalently on the web, it allows for secure messages to be sent between parties without having to agree on, or share, a secret key. It uses an asymmetric encryption scheme in which the encryption key is made public, but the decryption key is kept private.

7 0
3 years ago
Read 2 more answers
A​ _______ helps us understand the nature of the distribution of a data set.
Sphinxa [80]

Frequency distribution
3 0
2 years ago
A Computer Programmer who wants to be surrounded by a large number of like-minded coworkers should take a job with one of the na
vichka [17]

Answer:

C

Explanation:

This job will have the largest amount of 1. computer programmers, 2. like-minded coworkers, and 3. a large number of like-minded coworkers.

Please give Brainliest if accurate!

7 0
3 years ago
Read 2 more answers
The cell address ZZ123 means
mafiozo [28]
The range of cells from zz1 to zz23
7 0
2 years ago
Read 2 more answers
Other questions:
  • Pollution or waste that is generated from a business is called a
    6·2 answers
  • Oxygen-18 has an atomic number of 8. How many neutrons are in this isotope?
    7·1 answer
  • Plz help! 3 questions! 1.The ideal light to use is.... A.front light B.a combination of side and back light C.a combination of f
    10·1 answer
  • To reduce inflation, the Federal Reserve _____ the money supply. This action also causes the economy to shrink.
    13·2 answers
  • You modify a document that is saved on your computer. Where are the changes stored until you save the document?a. Radom access m
    15·1 answer
  • Jeremy wishes to create a site map for his website. What tag will surround the URL of his home page? A. B. C. D.
    8·1 answer
  • In JAVA,
    10·1 answer
  • Which of these is one of the primary concerns for protecting your family when online?
    9·2 answers
  • Which network component is used to connect one network to another? Which component delivers the message to the destination compu
    5·1 answer
  • Question 2 of 3
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!