I have an issue with following problem: spoj.com/problems/COINTOSS
I use following code which (in my console) returns correct answers:
using System;
namespace ConsoleApp7
{
class Program
{
static void Main(string[] args)
{
int cases = Convert.ToInt32(Console.ReadLine());
string[] answers = new string[cases];
for (int i = 0; i < cases; i++)
{
string full_input = Console.ReadLine();
string[] splited_input = full_input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
double n = Convert.ToDouble(splited_input[0]);
double m = Convert.ToDouble(splited_input[1]);
double a = Math.Pow(2, n + 1);
double b = Math.Pow(2, m + 1);
double result = Math.Round(a - b, 2);
answers[i] = result.ToString("0.00");
}
for (int j = 0; j < cases; j++)
{
Console.WriteLine(answers[j]);
}
}
}
}
However, on SPOJ, I get “Wrong Answer” error. Any idea why?