Let’s assume the problem statement was wrong, and it should have said ‘more than’.
Problem statement:
Your job is to tell how many candies will each student and the teacher
receive after the splitting is performed.
Editorial:
Handling [M=0] as a special case is one solution.
If M=0, then the algorithm provided in both the problem statement and editorial never terminates; it is undefined what happens after an infinite loop, not a special case.
my below code is not working but same code is one user post that is working
what problem, in my code
using System;
namespace SplittingCandies
{
class Program
{
static void Main(string[] args)
{
int t = int.Parse(Console.ReadLine());
for (int i = 0; i < t; i++)
{
string[] tc = Console.ReadLine().Split(' ');
if (ulong.Parse(tc[1]) == 0)
Console.WriteLine(tc[0] + " " + tc[1]);
Why do we need to subtract candies at each stage and find the modulus and quotient at each stage?
Can’t we do it directly and in one step? Divide N by K, the quotient gives the candies each student will receive and the remainder the candies left with the teacher
Actually, the M=0 case here was to be interpreted as a special case, since the teacher can’t divide the candies by any students, since there are 0 students. On this case, the teacher receives all N candies… I’m sad this problem failed on being as trivial as possible due to this sort of complications… About the usage of long long it was really intended