This post is all about the solution of the " A. Bestie" Codeforces Round #830 (Div. 2) Problem Statement.

Codeforces logo

Codeforces



Problem Statement :

You are given an array a that contains n integer arithmetic a1,a2,...,an. Friends asked you to find the largest common divisor (GCD) of all of the numbers in the array and equalize it to 1. You can do the foregoing in a single process:

Choose arbitrarily defined index from the arrangement 1in;


Users must determine the smallest total cost of operations that must be performed so that the GCD of all array figures equals 1.


Format of Input :

Evey test includes a number of tests. The first category represents the number t (1t500) of tests. The testing phase are described below.


Evey test court's first category represents each numeric value n (1n100) — the total number of texts in the dialogue.



The second sentence of each testing ground contains n protagonists "P" and "B," which describe different types of messages in the dialogue in chronologically. The text with the patient's inquiry is denoted by personality "P," and the text with the technical support manager's reply is denoted by the character "B." The first personality in the line is assured to be "P."


Format of the Output :

For Every Test case display output as Yes or No.


Also Check this out:-




Also Read :- Top Programming Languages of 2022 Click Here

Solution of the Problem: Click Here