Visual Studio 如何在Code Forces中提交我的C#代码?获取运行时错误

mwg9r5ms  于 2023-05-23  发布在  C#
关注(0)|答案(1)|浏览(211)

这是我的代码,它在VS 2022中运行良好,但当我试图在CodeForces中提交它时,我得到了一个运行时错误。
我该怎么解决呢????

using System;

class Program
{
    public static void Main(string[] args)
    {
        string? Val1 = Console.ReadLine(); 
        int Number1 = Convert.ToInt32(Val1);

        string? Val2 = Console.ReadLine(); 
        int Number2 = Convert.ToInt32(Val2);

        if (Number2 <= (Number1 + 1) / 2)
        {
            Console.WriteLine(Number2 * 2 - 1);
        }
        else
        {
            Console.WriteLine((Number2 - (Number1 + 1) / 2) * 2);
        }
    }
}
dly7yett

dly7yett1#

//if the test inputs in one line       
    var line = Console.ReadLine();
    var data = line.Split(' ');
    Number1  = int.Parse(data[0]);
    //first integer
    Number2  = int.Parse(data[1]); //second integer

相关问题