Advertisement
Artem_Chepurov

Ex2 Tink Back

Jun 29th, 2022 (edited)
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             ulong n, a, b;
  10.             ulong deductibleAmount = 0;
  11.             var input = Console.ReadLine();
  12.             if (input == null) return;
  13.             n = Convert.ToUInt64(input.Split(" ")[0]);
  14.             a = Convert.ToUInt64(input.Split(" ")[1]);
  15.             b = Convert.ToUInt64(input.Split(" ")[2]);
  16.             ulong summaToN = (1 + n) * n / 2;
  17.             for (ulong i = a; i <= n; i += a)
  18.             {
  19.                 deductibleAmount += i;
  20.             }
  21.  
  22.             for (ulong i = b; i <= n; i += b)
  23.             {
  24.                 if (i % a != 0)
  25.                 {
  26.                     deductibleAmount += i;
  27.                 }
  28.             }
  29.  
  30.             Console.WriteLine(summaToN - deductibleAmount);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement