Co tu jest nie tak? Cały czas TLE. Prościej się chyba nie da? Nie wiem, jest jakiś schemat pisania programu na SPOJ?
using System;
public class Test
{
public static void Main()
{
int number = 0;
int counter = 0;
int factorial = 0;
int tens = 0;
int firsts = 0;
int k = 0;
int i = 0;
counter = Convert.ToInt32(Console.ReadLine());
for (k = 1; k <= counter; k++)
{
factorial = 1;
number = Convert.ToInt32(Console.ReadLine());
for (i = 1; i <= number; i++)
{
factorial *= i;
}
tens = factorial / 10;
if(factorial < 10)
{
firsts = factorial - tens;
}
else
{
firsts = factorial - 10 * tens;
}
Console.WriteLine("{0} {1}", tens, firsts);
}
}
}
created
last reply
- 2
replies
- 625
views
- 2
users
- 1
link