PM2A Editorial

editorial
keteki
maths

#1

PROBLEM LINK:

Practice
Contest

Author: Chandan Boruah
Tester: Chandan Boruah
Editorialist: Chandan Boruah

DIFFICULTY:

EASY

PREREQUISITES:

Simple Math, Brute Force.

PROBLEM:

Given count of red balls, count of blue balls and count of reflective glasses. Print the number of ways in which the balls

QUICK EXPLANATION:

Find the number of ways in which red balls can be reflected, rest of the glasses can be used to reflect the blue balls. Count such number of ways.

EXPLANATION:

Iterate till the minimum of red balls and blue balls. Use the glasses to reflect from 0 to min(red,blue) balls. If its possible to reflect the blue balls with the glasses that are left in every iteration it should be counted.

AUTHOR’S SOLUTION IN C#:

using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		int t=int.Parse(Console.ReadLine());
		while(t>0)
		{
			t--;
			string[]ss=Console.ReadLine().Split();
			int red=int.Parse(ss[0]);
			int blue=int.Parse(ss[1]);
			int glasses=int.Parse(ss[2]);
			int count=0;
			for(int i=0;i<=Math.Min(red,glasses);i++)
			{
				int glass=glasses;
				glass-=i;
				if(blue>=glass)count++;
			}
			Console.WriteLine(count);
		}
	}
}