Uva Problems

March 24, 2018 | Author: Nadim Hussain | Category: Cricket, Physics & Mathematics, Mathematics, Science, Sports


Comments



Description

AArithmancy Hermione Granger, the most talented witch of her generation, likes to solve various types of mathematical problems in the Arithmancy class. Today, the professor has given her the following task: Find the number of fractions a/b such that1. gcd(a, b) = 1 2. 0 < a/b < 1 3. a * b = (n!) ^ (n!) Where “n!” denotes the factorial of n and “^” denotes power, i.e. (2!) ^ (2!) = 4. She is quite confident that she can solve it for n ≤ 10^7, but then she remembers that she has to study some case history so that she can help Hagrid to win the case of Buckbeak. So, she wants your help to solve the problem. Input There will be one line for each test case containing the number n (1 ≤ n ≤ 10^7). Input will be terminated by EOF. There will be around 20,000 test cases. Output For each case, print the number of fractions in a separate line. This number may be very large, so print the answer modulo 10,007. Sample Input 1 2 Output for Sample Input 0 1 [Type text] FEB. Similarly. [Type text] . Output You are to output the case number and the date in Decimal Calendar format. MMM stands for first three letters (in CAPS) of the month and YYYY stands for the year).B Calendar We know that there are so many calendar systems. NOV. Arabic. There are 60 days in this month. You are given a day in Christ calendar in DD-MMM-YYYY format (DD stands for day. MAY. OCT. DEC. And this followed by the last month “Ones” having 5 or 6 days depending on whether this is leap year or not. Every test case consists of a date in Christ Calendar format in each line. There are 3 months in this calendar. A year in Christ calendar is leap year if the year is divisible by 400 or divisible by 4 but not by 100. SEP. AUG. APR. There are 300 days in this month. MAR. JUN. Christ. and again 1900 is not leap year too. Second month is “Tens”. A Decimal year spans a full Christ calendar. This problem is about Decimal calendar. JUL. A year in Decimal calendar is leap year if the corresponding Christ year is leap year. First month is “Hundreds”. the Decimal year corresponding to 2000 Christ year is leap year but 2001 is not. Sample Input 3 01-JAN-1900 10-JAN-1900 16-DEC-1900 Note First three letters for the months are: Output for Sample Input Case 1: 1 Hundreds Case 2: 10 Hundreds Case 3: 50 Tens JAN. Bangla. For example. That is 1st Hundreds in Decimal Calendar is 1st January in Christi Calendar. 31st December of Christ Calendar is 5th or 6th day of Decimal calendar (depending on whether it is leap year or not). Output the date and the month in the Decimal Calendar. You are to give the date in Decimal Calendar format. For example. Chinese etc. Input First line contains number of test case. C Mr. they want to collect food as much as they can. output -1 (negative one) instead. Ant is a two dimensional grid.# . One can decide to not to move in some step. Sample Input 2 2 3 H#. and Mrs. One cell can be visited many times. To do so. In this problem. . The world of Mr. R lines follow giving the grid.. they eat together. Each cell is either the home. give the minimum amount of time that must be needed for them to collect all the foods and then meet. Ant are very hungry. and Mrs. Ant A food item Free (passable) cell Blocked cell Remarks Occurs exactly once Occurs at least once. or blocked. while other may move.H#.F Output for Sample Input Case 1: -1 Case 2: 8 [Type text] . the minimum amount of time (in seconds) that must be needed for them to collect all the foods and meet. and Mrs. they start from their house and collect all foods together and meet in some place (not necessarily their house). print the case number. and Mrs.. Ant Mr. Then. Each case starts with two integers R and C (2 ≤ R. Input The first line of input will contain T (T ≤ 30) denoting the number of cases. they can move from one cell to another cell simultaneously. They can search for foods simultaneously. Given the grid information. In each second. Finally.#F 2 6 F#F. (dot) # (hash) Meaning Home of Mr. Output For each case. the grid is given by an R x C matrix represented by following characters: Character H F . C ≤ 12). or contains a food. If it is impossible to collect all the food items. or free. So. at most 8 times. Both of them can move into the same cell also. Two cells are adjacent if they share an edge. then Australia tour to Bangladesh and now IPL T20. as you are watching second innings of the match. Nb for No Ball and W for Wicket) In cricinfo we always watch the score card.cricinfo. 6 In this over there were 1 wicket and 9 runs.com. W . it is not necessary to play an entire over to score N runs. That means. But for the purpose of this problem here is short description of scoring. You are to output number of ways of the outcome of the over. Any rule out of this problem description is not applicable for this problem. In the last over of second innings of a match. For this problem we will use only the following outcomes in a ball: Possible Outcome in a Ball . 1 2 3 4 6 Wd 1Wd 2Wd 4Wd Nb 1Nb 4Nb 6Nb W Runs 0 1 2 3 4 6 1 2 3 5 1 2 5 7 0 Is the Ball valid? Yes Yes Yes Yes Yes Yes No No No No No No No No Yes (Wd stands for wide. First World Cup Cricket. So I do not need to describe the game rule. A score card of an over may look like below: 1 . Also note that. Note that. Also suppose you do not know how many wickets are already gone. Wd Nb . if a team scores greater or equal to N runs the team wins and does not play any ball. [Type text] . so it may be possible that he can score N runs in first 4 balls and win the match.D Cricinfo I guess the most visited site of the past 3 months is www. I believe there are lots of cricket fans among you. In cricket an over consists of 6 valid balls. a team requires N runs to win. So it may also be possible that after a few wicket falls they are all out. [Type text] .Input First line contains number of test case T (T ≤ 10000). For each test a line contains N (1 ≤ N ≤ 10000). Output For every test case. Sample Input 1 1 Output for Sample Input Case 1: 946 Note Two ways are different if the outcome of a ball in the last over is different. As the answer can be very big. so output in mod 10000007. output the case number and number of ways of outcome of the last over where the team needs N runs to win. You have to tie wires to the poles. A pole might not have any wire attached to it. there are 4 possible valid configurations. As the number of ways is very big you have to output the result in modulo 1.E Pole and Wire There are N poles along a road side. These two wires crossed each other. Output For every test case you are to output number of test case and number of ways of valid configuration. T (T ≤ 300). You can attach two ends of a wire to two different poles. suppose there are 5 poles. Say a wire is from pole 1 to pole 4 and another from pole 2 to pole 5. Sample Input 2 3 4 Output for Sample Input Case 1: 4 Case 2: 9 Hint For N = 3. This is overlap.003. Input First line of the test file contains number of test cases. A pole also must not have more than one wire attached to it. For every test case you will be given number of poles N (1 ≤ N ≤ 10^5). Two wires must not cross each other but may overlap.000. so it is valid configuration. But say a wire is from pole 1 to pole 4 and another from pole 2 to pole 3. So such configuration is invalid. For example.     No wires attached Wire from Pole 1 to Pole 2 Wire from Pole 2 to Pole 3 Wire from Pole 1 to Pole 3 [Type text] .
Copyright © 2024 DOKUMEN.SITE Inc.