Created
April 26, 2015 21:33
-
-
Save EBojilova/25835c1f77a948a1f3bf to your computer and use it in GitHub Desktop.
02.Peters Game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Numerics; | |
class PetersGame | |
{ | |
static void Main(string[] args) | |
{ | |
ulong start = ulong.Parse(Console.ReadLine()); | |
ulong end = ulong.Parse(Console.ReadLine()); | |
string word = Console.ReadLine(); | |
BigInteger sum = 0; | |
for (ulong i = start; i < end; i++) | |
{ | |
if (i%5==0) | |
{ | |
sum += i; | |
} | |
else | |
{ | |
sum += i % 5; | |
} | |
} | |
var sumSymbols = sum.ToString(); | |
if (sum % 2 ==0) | |
{ | |
var first = sum.ToString().ToCharArray().First(); | |
sumSymbols = sumSymbols.Replace(first.ToString(), word); | |
} | |
else | |
{ | |
var last = sum.ToString().ToCharArray().Last(); | |
sumSymbols = sumSymbols.Replace(last.ToString(), word); | |
} | |
Console.WriteLine(sumSymbols); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment