By vazhadval, history, 2 years ago, ,

I get "runtime error on test 1" message and I think my code is OK

Problem name: Theater Square

CODE:

using System;

namespace ConsoleApp6 { class Program { static void Main(string[] args) {

int n = Convert.ToInt32(Console.ReadLine());
int m1 = 0;
int n1 = 0;
if (a >= m)
{
m1 = 1;
}
if(a<m)
{
m1 = m / a + 1;
}
if (a >= n)
{
n1 = 1;
}
if(a<n)
{
n1 = n / a + 1;
}
Console.WriteLine(m1 * n1);
}
}

}

• +2

 » 2 years ago, # |   0 The problem is in the way of getting the input.Search for how you can get many data given in one line in C#.Tell me if you don't get the information needed.
•  » » 2 years ago, # ^ | ← Rev. 2 →   +1 I thibk there is not such thing in C#
•  » » » 2 years ago, # ^ |   0 But there is. I have searched for it before I commented.
•  » » 15 months ago, # ^ |   +3 It helps me!Thanks!
 » 2 years ago, # |   0 When the line "Console.ReadLine()" runs, it reads the whole string which contains all numbers given in the input. So, when the line "int m = Convert.ToInt32(Console.ReadLine());" runs, there is no more numbers on the input.In other words: in that task you call "ReadLine()" 3 times. But the input have only one string. So, When you call "ReadLine()", you read all the input. You should call "ReadLine()" only once here
 » 2 years ago, # |   +1 I understand , thank you :)