Advertisement
nikolapetkov824

FromLeftToRight

Oct 4th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Numerics;
  4. using System.Linq;
  5.  
  6. namespace FromLeftToRight
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int n = int.Parse(Console.ReadLine());
  13. long realSum = 0L;
  14. for (int i = 0; i < n; i++)
  15. {
  16. long[] numbers = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  17. long a = numbers[0];
  18. long b = numbers[1];
  19. if (a>b)
  20. {
  21. for (int j = 1; j <= Math.Abs(numbers[0]); j++)
  22. {
  23. long numT = Math.Abs(a);
  24. long sumT = 0L;
  25. while (numT != 0)
  26. {
  27. sumT += Math.Abs(numT % 10);
  28. numT = numT / 10;
  29. }
  30. realSum = sumT;
  31. }
  32. }
  33. else
  34. {
  35. for (int j = 1; j <= Math.Abs(numbers[1]); j++)
  36. {
  37. long numG = Math.Abs(b);
  38. long sumG = 0L;
  39. while (numG != 0)
  40. {
  41. sumG += Math.Abs(numG % 10);
  42. numG = numG / 10;
  43. }
  44. realSum = sumG;
  45. }
  46. }
  47. Console.WriteLine(Math.Abs(realSum));
  48. realSum = 0L;
  49. }
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement