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
Which statement opens a text file so that you can retrieve the information it contains?
vesna_86 [32]

Answer:

Answered below

Explanation:

aFile = open("books.txt", "r")

This code uses the function open() which takes two parameters. The first parameter is the file name while the second parameter is the mode in which you are accessing the file.

The "r" mode opens the file in a reading state. That is, you can only read from the file. This code completes the reading process

aFile.read( )

The "w" mode opens the file so you can write to it and make changes.

The "a" mode opens the file so you can add contents to it.

3 0
2 years ago
What is the function of cpu while processing data?​
attashe74 [19]

Answer:

"Store date, intermediate results, and instructions (program."

Explanation:

"CPU is considered as the brain of the computer. CPU performs all types of data processing operations. It stores data, intermediate results, and instructions (program). It controls the operation of all parts of the computer."

3 0
2 years ago
Read 2 more answers
Which example task should a developer use a trigger rather than a workflow rule for?
Komok [63]

Answer:

A. To set the primary contact on an account record when it is saved

Explanation:

After updating a Contact and then you set the Primary checkbox, the contact becomes the primary contact and this then updates the reference in the Parent Account. Triggers are used for this purpose and not workflow rule. In this case there is only one contact at a time that is set as Primary Contacts, and in the case where an Account does not have any Contacts, the first contact that is created is made the primary and the trigger sets that value in reference.

6 0
3 years ago
What is self management.​
OLEGan [10]

Answer:

Self management is being able to control your emotion & behavior. This is a very important life skill

Explanation:

8 0
2 years ago
Read 2 more answers
Working ____ means that you are viewing previously loaded or saved webpages in the browser, but you are not connected to the int
uysha [10]
Working offline is the answer
8 0
3 years ago
Other questions:
  • Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
    8·1 answer
  • Named constants should be used when they serve to improve readability and understanding. T or F
    12·2 answers
  • What does it mean to clear a setting in a dialog box?
    14·1 answer
  • What is the forging of the return address on an email so that the email message appears to come from someone other than the actu
    11·1 answer
  • after pouring concentrated disinfectant on larger drops or pools of blood how much contact time should be allowed before attempt
    8·2 answers
  • Gun to yo head any last words??
    10·2 answers
  • Xercise 1<br>1.<br>What is system? Explain the components of system in brief.​
    12·1 answer
  • 4.8 code practice question 2 edhesive
    12·1 answer
  • Sharing resources.
    14·1 answer
  • Write a while loop that continues to increment uservalue by 5 as long as uservalue is less than 0.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!