Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3. using System.Text;
  4.  
  5. class PetersGame
  6. {
  7. static void Main()
  8. {
  9. BigInteger starting = BigInteger.Parse(Console.ReadLine()); //10
  10. BigInteger end = BigInteger.Parse(Console.ReadLine()); //14
  11. string replacement = Console.ReadLine(); //a
  12.  
  13. BigInteger sum = 0;
  14. string replays = string.Empty;
  15. string result = string.Empty;
  16.  
  17. for (BigInteger i = starting; i < end; i++)
  18. {
  19. if (i % 5 == 0)
  20. {
  21. sum += i;
  22. }
  23. else
  24. {
  25. sum += i % 5;
  26. }
  27.  
  28. if (sum % 2 == 0)
  29. {
  30. replays = sum.ToString()[0].ToString();
  31. }
  32. else
  33. {
  34. replays = sum.ToString()[sum.ToString().Length - 1].ToString();
  35. }
  36.  
  37. result = sum.ToString().Replace(replays, replacement);
  38. }
  39.  
  40. Console.WriteLine(result);
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement