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 m = Convert.ToInt32(Console.ReadLine()); int a = 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); } }
}
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.
I thibk there is not such thing in C#
But there is. I have searched for it before I commented.
It helps me!
Thanks!
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
I understand , thank you :)