+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Ali is a member of Triangulum team and is really smart. But you know, nothing in this world can have all goodies. Goldfish’s memory works better than his(!!). One time he solved hardest problem of a contest, when Mohsen asked him “How did you solve it?”, he replied with: “I solved it? did i? Are you sure i solved it? No i did not!”, he couldn’t remember. Because of his memory, he always forgets where he left his cellphone. Farzad & Amin - his teammates - always have to wait for him to find his cellphone. But Farzad & Amin are in hurry so they need to know how long they should wait. There are N rooms in Shahid Beheshti University where Ali may left his cellphone, He starts looking. it takes $t_1$ seconds to search a room and $t_2$ seconds to go from a room to another one. Ali is not lucky at all, he has worst luck on earth. He always finds his cellphone in last room. Can you help Farzad & Amin to figure out how long they should wait?!
# ورودی
First line of input contains an integer $T(1 \le T \le 106)$, indicating number of test cases. Each test case contains three integers in a line, $N (1 ≤ N ≤ 1000), t_1 , t_2 (1 ≤ t_1, t_2 ≤ 100)$ indicating number of rooms, time needed to search a room and time needed to change a room respectively.!
# خروجی
For each test case print an integer in a line indicating time Farzad & Amin have to wait.!
# مثالها
## ورودی نمونه ۱
```
2
1 10 2
10 9 3
```
## خروجی نمونه ۱
```
10
117
```
A – Ali the Forgetter
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
-----
One day Amin and Ali and Farzad - Triangulum Team members - were sitting in ACM room. Amin likes numbers a lot so he wanted to make a sequence. In order to do it, he asked his teammates for cooperation. Amin came up with number 1 as first number of the sequence and wrote it down on the Whiteboard. Then, Ali declared 4 as second number of the sequence and wrote it down too. Ali was going for an Arithmetic-Sequence where every number is calculated using it’s $previousNumber +
ConstantValue$ (here $ConstantValue$ is 3). Farzad doesn’t like Arithmetic-Sequences so he came up with a plan to ruin Ali’s idea. After a while, Farzad declared 9 as third number of the sequence and wrote it too. All of a sudden Shamir just walked into the ACM room and said: $Waazzzzaaaaauuuup?😝️$!!! and saw the numbers written on the Whiteboard. Shamir’s eyes do not see numbers very clearly because he just got back from SoGood restaurant (KFC or KF…) and he ate too much chickens there so he’s not feeling ok. He sees & writes numbers in reverse. He guesses that each element of sequence is square of a number n. Shamir likes coding a lot and that’s why when he finds an interesting sequence of numbers, he just have to code it immediately. But he’s not feeling ok due to the damage he received in restaurant and that’s why he asked you for help. He needs you to write a program that calculates square of number n and then prints it in reverse(For example reverse of the number $1243$ is $3421$)!
# ورودی
The input file contains several test cases. each test case contains an Integer $N(0 < N ≤ 10^9 )$ in a line!(count of lines is less than 2000).
# خروجی
For each test case print a number in a line as requested. (if there are any trailing zeros, print them)!
# مثالها
## ورودی نمونه ۱
```
1
2
3
11
```
## خروجی نمونه ۱
```
1
4
9
121
```
B – Triangulum Number or rebmuN mulugnai
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Some planet exist in the Shekami Way Galaxy. These planets all have the same size and they are completely spherical. Creatures that are living on each of these planets are called $Shamirium$. Each of these planets have infinite amount of delicious foods like $Pesteh$, $Pashmak$ and $Baghali$ $Polo$ $Ba$ $Mahicheh$ and also lots of drinks like $Pinacolada$ , $Ab$ $Havij$ $Bastani$ and $\dots$ and non of these drinks are alcoholic! None of these planets have mountains, valleys nor long departments. All of the Shamiriums in the Shekami way galaxy are friends with each other and they are very kind persons and they never fight with each other except for the FOODs!
![توضیح تصویر](https://quera.org/qbox/view/Sv4T3Fdcwz/C.png)
However they have foods enough for supplying thousands of years for their own
residents. But they still jealous at other planets foods! After they produce the foods, they need some place in their planet to store them so that the people on the other planets can’t see their foods. During all of the galaxy’s history, Shamiriums are only eating foods so their technology has not improved since they invented the telescope – even they use the telescope for seeing the other planets foods! So they are searching for blind spots so that their garner is far from the other planets site seeing. It is possible that some of the planets don’t have any blind spots to build their garner. Your task is to calculate total area of blind spots of all planets.
# ورودی
First line of the input contains an integer $T(1 \le T \le 200)$, the number of test cases to follow. Each test case start with an integer $N (2 ≤ N ≤ 50)$ indicating the number of planets and $R (0 < R ≤ 1000)$ an integer indicating radios of planets. Following N lines contain positive pairs of integers $xi , yi (|xi| , |yi| ≤ 1,000,000)$ indicating the coordinates of the $i$’th planet. Of course planets do not intersect, so it is guaranteed that input is valid.
# خروجی
For each test case output “Case #X: A” (quotations for clarify) which X is number of the test case and A is the answer as described above with exactly three decimal digits.
# مثالها
## ورودی نمونه ۱
```
1
2 2
1 1
100 100
```
## خروجی نمونه ۱
```
Case #1: 50.265
```
C – Shekami Way Galaxy
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
ARTICLE 137:
***When Hosting, a Bro orders enough pizza for all his Bros.***
![توضیح تصویر](https://quera.org/qbox/view/nH7ppzEqwd/D.png)
When Hosting other friends, it’s important to have enough foods. One easy way is to buy pizzas. We have an equation for calculating number of pizzas: $ p = \left \lceil \frac{h \times b}{8} \right \rceil$ where $p$ is number of pizzas to buy ($\left \lceil \right \rceil $ is Ceil function), $b$ is number of Bros (including the host) and $h$ is the hunger ratio. we have another equation to calculate $hunger$ $ratio:$ $h = \frac{m}{t}$ where $m$ is average gravitational mass of the Bros and $t$ is the time period a Bro will get hungry.
Every Bro have to eat at least $h'$ = ⎣$h$⎦ pieces (⎣ ⎦ is Floor function). Given the variables $m$, $t$ and $b$. Your task is to calculate how many pizzas should the host Bro buy, and what is the maximum number of pieces a single Bro can eat such that his other Bros ate at least $h'$ pieces.
# ورودی
First line of the input contains an integer $T (T ≤ 137)$ indicating number of test cases to follow. Each test case contains three space separated integers indicating variables $m$, $t$ and $b$ $(100≤m≤10000, 1≤ t ≤ m, 1≤ b ≤24)$.
# خروجی
For each test case print a line of output containing two integers separated with a single space indicating number of $pizzas$ to buy and maximum number of pieces a single Bro can eat such that his other Bros ate at least $h'$ pieces.
# مثالها
## ورودی نمونه ۱
```
4
100 20 8
100 20 9
100 19 8
100 19 9
```
## خروجی نمونه ۱
```
5 5
6 8
6 13
6 8
```
D – The Bro Code
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
In the dormitory, people will take turns to buy dinner or stuff for dinner. Each night one person goes out to buy and writes details of it on the “Detail Paper”. Details include name of the buyer, amount of money he/she paid and name of the people ate that night.
![توضیح تصویر](https://quera.org/qbox/view/ETZ1Iu4bxa/E.png)
At the end of each month everybody have to pay their debts, But everyone get’s so creepy when it comes to money. So they all decided to hire a team from ACM(Abdominal Control Market) of the SBU University. you are one of the teams participating in ACM Newbies Contest so you have to help them. They only have two rules:
1. Only people that ate, should pay (name of them is written in Detail Paper)
2. The money paid by everyone on each night must be equal.
# ورودی
There are some test cases in one test(at most 200), Each test case contains an integer $L (L ≤ 50)$, number of lines to follow. Each line of test case is as following: A string $S$ name of the buyer followed by an integer $C(0<C<100000)$ cost of things bought followed by an integer $N(N≤10)$, indicating how many people ate that specific night, Following $N$ space separated strings indicating $name$ of the people that ate that night. It’s guaranteed that $C$ is divisible by $N$ and Each
line contains no more than $250$ characters.
Each $Name$ contains “A-Z” and “a-z” characters. $Names$ are NOT case-sensitive and length of each name is at most 20 characters. (Case-Sensitive: ‘a’ ≠ ‘A’, not case-sensitive: ‘a’ = ‘A’)
# خروجی
For each test case output “**Case #X:**” (quotations for clarify) which $X$ is the number of test case. Then print “**Debtors:**” (quotations for clarify) and in each line print name of debtors and their liability as following sorted by debtors name in alphabetical order:
**S owes D Tomans.**
First alphabetical character of $S$ must be uppercase and rest of alphabetical characters must be lowercase, $D$ is an integer number (money person $S$ must pay).
Then print “**Creditors:**” (quotations for clarify) and in each line print name of creditors and their credit as following sorted by creditors name in alphabetical order:
**S paid D Tomans.**
First alphabetical character of $S$ must be uppercase and rest of alphabetical characters must be lowercase, $D$ is an integer number (money person $S$ must get). People who don’t have to pay or receive any money are neither Debtor nor Creditor, so their name should not appear in output.
# مثالها
## ورودی نمونه ۱
```
10
Michel 9200 4 Aden John David Michel
Ashley 8700 3 Ashley Aden John
Ashley 6000 3 Michel John Ashley
Aden 15000 3 Ashley John Aden
Michel 1800 4 Aden David Michel Ashley
David 2200 4 Aden John David Ashley
Aden 29400 3 Aden David Ashley
Aden 8500 4 Aden David Ashley John
John 21000 3 Aden Michel John
Aden 3100 2 Aden Michel
1
Ehsan 4500 1 ehsan
```
## خروجی نمونه ۱
```
Case #1:
Debtors:
Ashley owes 8125 Tomans.
David owes 13025 Tomans.
John owes 875 Tomans.
Michel owes 2300 Tomans.
Creditors:
Aden paid 24325 Tomans.
Case #2:
Debtors:
Creditors:
```
E – Dormitory Nights
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
One of the SBU ACM teams, Triangulum wants to trip to Kanpur for an important regional contest. They should travel by bus and as you know it could be an incredibly boring trip. During their trip they need to take rest in some hotels. There are N hotels in the path of Tehran to Kanpur. They should choose some hotels to take a rest at (maybe more than one night), and finally they must rest at $N$’th hotel. If they travel for $D$ distances between two hotels they should tolerate $|D-144|$ unit of difficulties. Given distance of each hotel from Tehran, your task is to help them to choose some
hotels in order to minimize total difficulties as much as possible.
For more clarification, see sample inputs and outputs.
# ورودی
Your program will be tested on one or more test cases. The first line of the input will be a single integer $T(T \le 30)$, the number of test cases. The first line of each test case will contain integers $N$, the number of hotels. Next line contains $N$ space separated integer numbers, each indicating $D_i$ , distance from Tehran to $i$’th hotel (in increasing order).$D_i < 10000$ and $N ≤ 20$.
# خروجی
For each test case print a single line containing minimum total difficulties.
# مثالها
## ورودی نمونه ۱
```
3
1
10
2
120 144
4
10 14 20 21
```
## خروجی نمونه ۱
```
134
0
123
```
F – Road to Kanpur
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Mohsen and Mohammadreza are teammates. They are participating in Codeforces’es contest called Gym every week. Like always Mohammadreza was late, so Mohsen started calling him. Their cellphones are always in silent mode so they don’t understand if someone is calling them. Mohsen kept calling and finally gave up. They both always check their cellphones every 10 hours. When Mohammadreza checks his cellphone he sees lots of missed calls!!! so he starts calling back Mohsen. Mohsen misses them too, Then, Mohsen checks his cellphone and starts calling Mohammadreza and this continues for hours. They can’t reach each other and because of that they miss the contest. Mohsen got bored so he started to make a problem for Newbies Contest.
He wrote number of times they called each other on a paper. He wrote number of Mohsen’s miss calls as a positive number and number of Mohammadreza’s miss calls as a negative number. Mohsen was wondering what is the longest interval that multiply of numbers within it, is maximum among any other interval?
# ورودی
First line of input contains an integer $T(T \le 100)$ indicating number of test cases. Each test case contains two lines. First line contains an integer $N(1 ≤ N ≤ 100)$ indicating number of times they called each other. Second line contains a list of non-zero integers $a_1 ,a_2 ,\dots,a_n (a_i ≤ 50)\space$ separated with spaces.
It’s guaranteed there is at least one negative integer in every 10 consecutive integers.
NOTE: It’s possible that only one of them calls other person.
# خروجی
For each test case print a line containing two integers $L$ and $R$ separated with a single space, indicating the interval $[L, R]$, where answer of $a_L \times a_{L+1} \times\dots\times a_R \space$ is maximum. If there is more than one solution, print the one with smaller $L$ and then longer interval.
# مثالها
## ورودی نمونه ۱
```
3
5
1 2 3 -4 -5
5
10 21 -3 40 38
5
5 20 -3 5 20
```
## خروجی نمونه ۱
```
1 5
4 5
1 2
```
G – Gym Contest
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
Nowadays everything depends on exchange rate of dollar (Now it is called *rate* due to its importance). Total atmosphere of our country has been affected by *rate*. But this is not the only reason of economical disorders. Some of sellers called "*traitors*" cause the other reason. These sellers act different in different rate swings:
+ In rate increment, they increase the price of goods bought before and pretext: "I must increase because I need to buy this good again".
+ In rate decrement, they don't decrease the price of goods bought before and pretext: "I paid more and decrement has lots of damages for me”.
Actually if *rate* changes from $r_1$ to $r_2$ (and $r_2 > r_1$ ), *traitors* multiply their price to $\frac{r_2}{r_1}$ and round the product to the nearest(if distances were equal, to upper nearest) multiple of *round base*. For example if a *traitor* bought a pen $1000_{Rials}\space$ in first day and *rate* changed from $8000_{Rials}\space$ to $23000_{Rials}$ and then to $12000_{Rials}\space$, and round base was $100_{Rials}\space$, finally he sells this pen $2900_{Rials}\space$. because:
$100 \times 28 < 1000 \times \frac{23000}{8000} = 2875 \le 100 \times 29$ and $2875$ is closer to $2900$.
Ali wants to buy a battery for his laptop. But there is only one shop selling this kind of battery. Ali knows that this shop's seller is a *traitor* and has this battery since **n** days ago. Ali went to this shop and realised that the seller sells the battery **p** Rials and round base for this shop is **b** Rials. Ali wants to know how much was this battery's price **d** days ago. He is busy preparing problems for SBU Newbies Contest so he needs your help.
# ورودی
The input file contains several input sets. The description of each set is given below:
Each set starts with four integers $n (0 ≤ n ≤ 10^5)$, the number of days passed from seller's buy, $p (0 ≤ p ≤ 10^9)$, the price of battery, $b (1 ≤ b ≤ 10^5)$, round base, and $d (0 ≤ d ≤ n)$, the number of days passed from Ali's slightly day, following a line with $n + 1$ non-negative space separated integers $r_0, r_1, \dots, r_n\space$. $r_i$ equals the rate when $i$ days passed from seller's buy. Actually $r_0$ equals the rate when seller bought the battery. It is guaranteed that Input will follow the descriptions given.Input is terminated by a set where $n=p=b=d=0$ which should not be processed. There is a blank line between two input sets. sum of $n$ over all input sets are at most $2\times 10^5$ and count of input sets are less than $20$.
# خروجی
For each input set, produce one line of output including space separated $m$ and $M$ which respectively mean the least and the most possible prices the battery could have in d days ago.
# مثالها
## ورودی نمونه ۱
```
1 15000 1000 1
8000 12000
2 45000 1000 2
8000 36000 12000
3 20 4 1
1 5 4 3
0 0 0 0
```
## خروجی نمونه ۱
```
9667 10333
9889 10111
20 20
```
H – Exchange Rate
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
![توضیح تصویر](https://quera.org/qbox/view/Ccla7S035X/I.png)
Once upon a time Mohammadreza and Mehrdad (M&M) decided to go to jungle to bring as many coconuts as possible. But unfortunately “Mehrzad the Kaftar” (his friends call him “**Lion**”) was following them. M&M are smart so they realised Lion was following them. When they just realised it, Mohammadreza climbed a tree and said to Mehrdad “Ble Ble Ble”!!!. Mehrdad couldn’t understand what Mohammadreza was saying and he was unable to climb trees so he ran. Mehrdad is good with geography so he knows jungle very well. He knows that there are some fences that
only Lion can pass through (Lion jumps over it and takes 2 seconds) and some other fences that no one can pass (not Lion nor Mehrdad). There are also some Tunnels that Lion can not reach, so if Mehrdad gets there, he’s safe. Mehrdad is frightened so he can’t think, the only thing he can do is run. Mehrdad and lion move one cell at a time (1 second) and they can only move in four directions: up, down, left, right. Can you help him?
# ورودی
First line of the input contains an integer $T (T ≤ 20)$ indicating number of test cases to follow. The first line of each test case will be given two integers $N$ and $M (1 ≤ N,M ≤ 500)$, the height and width of the jungle. Each of the following $N$ lines contain $M$ characters, describing the jungle. if $J$’th character of $i$’th line is ‘**.**’ it’s free cell, if it’s ‘**M**’ Mehrdad is there, if it’s ‘**L**’ Lion is there, if it’s ’**O**’
there is a tunnel there, if it’s ‘**#**’ there’s a long fence there and if it’s ‘**+**’ there’s a small fence there. If Mehrdad and Lion reach at same cell in a same time, Mehrdad will be eaten by Lion.
It’s guaranteed there are no more than 10 tunnels, and Mehrdad can always reach at least one tunnel (but he may be eaten in the way).
# خروجی
For each test case output a line containing “Case $X$: ” (quotations for clarify) which $X$ is number of the test case. If Mehrdad can’t survive print “$good$ $bye$ $my$ $dear$ $good$ $friend$ $:($” (quotations for clarify). If Mehrdad can survive print the position of top left most (first $Top$, Then $Left$) tunnel he can reach.
# مثالها
## ورودی نمونه ۱
```
2
1 12
O.+.M..L..O.
1 12
O...M..L..O.
```
## خروجی نمونه ۱
```
Case 1: good bye my dear good friend :(
Case 2: 1 1
```
I – Jungle of Coconuts
+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۲۵۶ مگابایت
----------
![توضیح تصویر](https://quera.org/qbox/view/UVvEZQeUxY/J.png)
Shamir’s birthday party will be held soon and for this big event, he bought $N$ cakes (YES!!! he bought them from BB). He didn’t have enough space in his house, so he brought them to ACM room. Shamir left ACM room for a minute, meanwhile Fata showed up! Fata is always hungry, there is nothing that can fill that void (that’s what he says about his stomach!). Fata saw cakes and became very happy for the situation and thanked god for his delightful blessing and started picking. After a while it wasn’t
picking anymore, he was literally cutting cakes. All of a sudden he remembered that there is a Newbies Contest coming up and he’s one of the problem setters, so he forgot about eating and started thinking about problems of the contest and cakes that will be dealt among the contest and drinks and $\dots$ so he left the room. When Shamir returned to the ACM room and saw cakes, he realised it’s Fata’s job. No one knows why, but Shamir wants to replace cakes that Fata picked on. Shamir doesn’t remember shapes of every cake so there is only one way for him to find out if a cake is picked on by Fata or not. Shamir remembers that all cakes were shaped as convex *polygons*(A plane figure with at least three straight sides and angles, and typically five or more), so if a cake is not *convex* (A polygon such that no side extended cuts any other side or vertex; it can be cut by a straight line in at most two points) anymore, Fata picked on that cake. Shamir is busy celebrating so he asked you for help.
This picture illustrates the shape of cake, before and after Fata shows up.!
![توضیح تصویر](https://quera.org/qbox/view/8YcVn5cupg/J_2.png)
# ورودی
In first line of the input will be an integer $N (1 ≤ N ≤ 20)$ indicating number of cakes. Each Cake is described by it’s corner points and shaped as a polygon. For each cake there is an integer $M (3 ≤ M ≤ 100)$ indicating number of cake’s corner points. Following $M$ lines, contain details of cake’s corner points in clockwise order. Each point is consisted of two integers $xi , yi (0 < xi , yi ≤ 10,000)$. It’s guaranteed there are not three points in a line.
# خروجی
For every cake given in input, output a line containing “Case $X$: ” (quotations for clarify) which $X$ is number of the test case and print “$YES$” or “$NO$” indicating $i$’th cake was picked on by Fata or not. if yes, then print “$YES$” otherwise print “$NO$” (quotes for clarify).
# مثالها
## ورودی نمونه ۱
```
1
3
6 2
1 1
3 5
```
## خروجی نمونه ۱
```
Case 1: NO
```