Posts

Showing posts from June, 2020

A. FashionabLee

Image
A. FashionabLee time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lee is going to fashionably decorate his house for a party, using some regular convex polygons... Lee thinks a regular   𝑛 n -sided (convex) polygon is   beautiful   if and only if he can rotate it in such a way that at least one of its edges is parallel to the   𝑂 𝑋 O X -axis and at least one of its edges is parallel to the   𝑂 𝑌 O Y -axis at the same time. Recall that a regular   𝑛 n -sided polygon is a convex polygon with   𝑛 n   vertices such that all the edges and angles are equal. Now he is shopping: the market has   𝑡 t   regular polygons. For each of them print   YES   if it is beautiful and   NO   otherwise. Input The first line contains a single integer   𝑡 t   ( 1 ≤ 𝑡 ≤ 10 4 1 ≤ t ≤ 10 4 ) — the number of polygons in the market.   Each of the next   𝑡 t   lines contains a single integer     𝑛 𝑖 n i   (

Number of triangles

Image
You are given a polygon of  N  sides with vertices numbered from  1 ,   2 ,   . . . ,   N . Now, exactly   2  vertices of the polygons are colored black and remaining are colored white. You are required to find the number of triangles denoted by  A  such that: The triangle is formed by joining only the white-colored vertices of the polygon. The triangle shares at least one side with the polygon. Input format The first line contains  t   denoting the number of test cases. Next   t   lines contain three space-separated integers   N ,  B 1 , and  B 2  where  N  is the number of sides in the polygon and  B 1 , B 2 denote the vertices that are colored black. Output format For each test case, print the answer   A  representing the number of triangles that can be formed with the given conditions in the problem statement.  Constraints 1 ≤ t ≤ 100 5 ≤ N ≤ 10 5 1 ≤ B 1 , B 2 ≤ N SAMPLE INPUT 1 6 2 5 SAMPLE OUTPUT 4 Explanation The number of

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius