Created
August 19, 2018 17:45
-
-
Save NastenaL/aef502c5ce2bce67e783158b7d7bc9c5 to your computer and use it in GitHub Desktop.
123B codeforces.com
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.Text; | |
using System.Threading.Tasks; | |
namespace toys | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
string s = Console.ReadLine(); | |
string[] values = s.Split(' '); | |
long n = long.Parse(values[0]); | |
long k = long.Parse(values[1]); | |
long count = 0; | |
ulong[] t = new ulong[n]; | |
for (long i = 0; i < n; i++) | |
{ | |
t[i] = (ulong)(n - i); | |
} | |
for (long i = 0; i < n; i++) | |
{ | |
for (long j = i + 1; j < n; j++) | |
{ | |
if ((long)(t[i] + t[j]) == k) | |
count++; | |
} | |
} | |
Console.WriteLine("count =" + count); | |
Console.ReadKey(); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Ошибка: " + e); | |
} | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment