Question: Programming Challenge Description: You will be given a positive integer N, and two single-digit integers p and q, where p != q and both are

Programming Challenge Description:

You will be given a positive integer N, and two single-digit integers p and q, where p != q and both are greater than 1. You must output all of the integers from 1 to N inclusive, separated by a comma ','.

However, any integer divisible by p or q should be replaced by the text OUT and any integer whose decimal representation contains digit p or q should be replaced by the text THINK. Integers for which both of the preceding statements are true should instead be replaced by the text OUTTHINK.

Input: A single line on standard input per test case: N p q

Output: The comma-separated sequence as described above (only numbers and uppercase chars), with no leading or trailing spaces.

Test 1

Test Input

Download Test Input

20 3 4 

Expected Output

Download Test Output

1,2,OUTTHINK,OUTTHINK,5,OUT,7,OUT,OUT,10,11,OUT,THINK,THINK,OUT,OUT,17,OUT,19,OUT 

Test 2

Test Input

Download Test Input

7 2 3 

Expected Output

Download Test Output

1,OUTTHINK,OUTTHINK,OUT,5,OUT,7 

Code that has to be completed:

using System; using System.IO; using System.Collections.Generic; using System.Text;

class Program { static void Main(string[] args) { using (StreamReader reader = new StreamReader(Console.OpenStandardInput())) while (!reader.EndOfStream) { string line = reader.ReadLine(); Console.WriteLine(line); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!