Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- using System.Text;
- class PetersGame
- {
- static void Main()
- {
- ulong starting = ulong.Parse(Console.ReadLine()); //10
- ulong end = ulong.Parse(Console.ReadLine()); //14
- string replacement = Console.ReadLine(); //a
- BigInteger sum = 0;
- string replays = string.Empty;
- string result = string.Empty;
- for (ulong i = starting; i < end; i++)
- {
- if (i % 5 == 0)
- {
- sum += i;
- }
- else
- {
- sum += i % 5;
- }
- }
- replays = sum.ToString();
- if (sum % 2 == 0)
- {
- char toReplace = replays[0];
- result = ReplaceInString(toReplace, replays, replacement);
- }
- else
- {
- char toReplace = replays[replays.Length - 1];
- result = ReplaceInString(toReplace, replays, replacement);
- }
- Console.WriteLine(result);
- }
- public static string ReplaceInString(char toReplace, string replays, string inputReplace)
- {
- string result = "";
- for (int i = 0; i < replays.Length; i++)
- {
- if (replays[i] == toReplace)
- {
- result += inputReplace;
- }
- else
- {
- result += replays[i];
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement