Problem J1: Quadrant Selection Time limit: 1 second Problem Description A commo
Problem J1: Quadrant Selection Time limit: 1 second Problem Description A common problem in mathematics is to determine which quadrant a given point lies in. There are four quadrants, numbered from 1 to 4, as shown in the diagram below: x y Quadrant 3 Quadrant 2 Quadrant 1 Quadrant 4 A (12, 5) B (-12, 5) C (-12, -5) D (12, -5) For example, the point A, which is at coordinates (12, 5) lies in quadrant 1 since both its x and y values are positive, and point B lies in quadrant 2 since its x value is negative and its y value is positive. Your job is to take a point and determine the quadrant it is in. You can assume that neither of the two coordinates will be 0. Input Specification The first line of input contains the integer x (−1000 ≤x ≤1000; x ̸= 0). The second line of input contains the integer y (−1000 ≤y ≤1000; y ̸= 0). Output Specification Output the quadrant number (1, 2, 3 or 4) for the point (x, y). Sample Input 1 12 5 Output for Sample Input 1 1 Sample Input 2 9 -13 Output for Sample Input 2 4 Version franc ¸aise sont apr` es la version anglaise Probl` eme J1 : D´ etermination du quadrant Description du probl` eme En math´ ematiques, il faut souvent d´ eterminer dans quel quadrant un point est situ´ e. Il y a quatre quadrants, appel´ es 1er, 2e, 3e et 4e quadrants, comme dans la figure suivante : x y 3e quadrant 2e quadrant 1er quadrant 4e quadrant A (12, 5) B (-12, 5) C (-12, -5) D (12, -5) Par exemple, le point A, qui a pour coordonn´ ees (12, 5), est situ´ e dans le 1er quadrant puisque ses coordonn´ ees (les valeurs de x et de y) sont toutes deux strictement positives, tandis que le point B est situ´ e dans le 2e quadrant puisque son abscisse (la valeur de x) est strictement n´ egative et son ordonn´ ee (la valeur de y) est strictement positive. ` A partir des coordonn´ ees d’un point donn´ e, vous devez d´ eterminer dans quel quadrant le point est situ´ e. Vous pouvez supposer qu’aucune des deux coordonn´ ees ne sera ´ egale ` a 0. Pr´ ecisions par rapport aux entr´ ees La premi` ere ligne d’entr´ ee contiendra un entier x (−1000 ≤x ≤1000; x ̸= 0). La deuxi` eme ligne d’entr´ ee contiendra un entier y (−1000 ≤y ≤1000; y ̸= 0). Pr´ ecisions par rapport aux sorties La sortie sera le num´ ero (1, 2, 3 ou 4) du quadrant dans lequel le point (x, y) est situ´ e. Exemple d’entr´ ee 1 12 5 Sortie pour l’exemple d’entr´ ee 1 1 Exemple d’entr´ ee 2 9 -13 Sortie pour l’exemple d’entr´ ee 2 4 English version appears before the French version Problem J2: Shifty Sum Time limit: 1 second Problem Description Suppose we have a number like 12. Let’s define shifting a number to mean adding a zero at the end. For example, if we shift that number once, we get the number 120. If we shift the number again we get the number 1200. We can shift the number as many times as we want. In this problem you will be calculating a shifty sum, which is the sum of a number and the numbers we get by shifting. Specifically, you will be given the starting number N and a non-negative integer k. You must add together N and all the numbers you get by shifting a total of k times. For example, the shifty sum when N is 12 and k is 1 is: 12 + 120 = 132. As another example, the shifty sum when N is 12 and k is 3 is 12 + 120 + 1200 + 12000 = 13332. Input Specification The first line of input contains the number N (1 ≤N ≤10000). The second line of input contains k, the number of times to shift N (0 ≤k ≤5). Output Specification Output the integer which is the shifty sum of N by k. Sample Input 12 3 Output for Sample Input 13332 Version franc ¸aise sont apr` es la version anglaise Probl` eme J2 : Somme d´ eplac´ ee Description du probl` eme On consid` ere un nombre, par exemple 12. On d´ efinit le d´ eplacement d’un nombre comme ´ etant l’ajout d’un z´ ero ` a la fin du nombre. Par exemple, si on d´ eplace le nombre 12 une fois, on obtient le nombre 120. Si on d´ eplace le nombre une deuxi` eme fois, on obtient le nombre 1200. On peut d´ eplacer le nombre aussi souvent que l’on veut. Dans ce probl` eme, vous allez calculer la somme d´ eplac´ ee, c’est-` a-dire la somme du nombre et de tous les nombres obtenus par ses d´ eplacements. On vous donnera un nombre N et un entier non n´ egatif k. Vous devez additionner N et tous les nombres obtenus en le d´ eplac ¸ant un total de k fois. Par exemple, si N est 12 et k est 1, la somme d´ eplac´ ee est : 12 + 120 = 132. Si N est 12 et k est 3, la somme d´ eplac´ ee est : 12 + 120 + 1200 + 12000 = 13332. Pr´ ecisions par rapport aux entr´ ees La premi` ere ligne d’entr´ ee contiendra le nombre N (1 ≤N ≤10000). La deuxi` eme ligne d’entr´ ee contiendra k, le nombre de d´ eplacements de N (0 ≤k ≤5). Pr´ ecisions par rapport aux sorties La sortie sera l’entier qui est ´ egal ` a la somme d´ eplac´ ee de N par k d´ eplacements. Exemple d’entr´ ee 12 3 Sortie pour l’exemple d’entr´ ee 13332 English version appears before the French version Problem J3: Exactly Electrical Time limit: 1 second Problem Description You live in Grid City, which is composed of integer-numbered streets which run east-west (parallel to the x-axis) and integer-numbered avenues which run north-south (parallel to the y-axis). The streets and avenues have infinite length, and there is a street for every integer y-coordinate and an avenue for every x-coordinate. All intersections are labelled by their integer coordinates: for example, avenue 7 and street -3 intersect at (7,-3). You drive a special electric car which uses up one unit of electrical charge moving between adjacent intersections: that is, moving either north or south to the next street, or moving east or west to the next avenue). Until your battery runs out, at each intersection, your car can turn left, turn right, go straight through, or make a U-turn. You may visit the same intersection multiple times on the same trip. Suppose you know your starting intersection, your destination intersection and the number of units of electrical charge in your battery. Determine whether you can travel from the starting intersection to the destination intersection using the charge available to you in such a way that your battery is empty when you reach your destination. Input Specification The input consists of three lines. The first line contains a followed by b, indicating the starting coordinate (a, b) (−1000 ≤a ≤1000; −1000 ≤b ≤1000). The second line contains c followed by d, indicating the destination coordinate (c, d) (−1000 ≤ c ≤1000; −1000 ≤d ≤1000). The third line contains an integer t (0 ≤t ≤10 000) indicating the initial number of units of electrical charge of your battery. For 3 of the 15 available marks, 0 ≤a, b, c, d ≤2. For an additional 3 of the 15 marks available, t ≤8. Output Specification Output Y if it is possible to move from the starting coordinate to the destination coordinate using exactly t units of electrical charge. Otherwise output N. Sample Input 1 3 4 3 3 3 Output for Sample Input 1 Y Version franc ¸aise sont apr` es la version anglaise Explanation for Output for Sample Input 1 One possibility is to travel from (3, 4) to (4, 4) to (4, 3) to (3, 3). Sample Input 2 10 2 10 4 5 Output for Sample Input 2 N Explanation for Output for Sample Input 2 It is possible to get from (10, 2) to (10, 4) using exactly 2 units of electricity, by going north 2 units. It is also possible to travel using 4 units of electricity as in the following sequence: (10, 2) →(10, 3) →(11, 3) →(11, 4) →(10, 4). It is also possible to travel using 5 units of electricity from (10, 2) to (11, 4) by the following sequence: (10, 2) →(10, 3) →(11, 3) →(12, 3) →(12, 4) →(11, 4). It is not possible to move via any path of length 5 from (10, 2) to (10, 4), however. Version franc ¸aise sont apr` es la version anglaise Probl` eme J3 : Exactement ´ electrique Description du probl` eme Les uploads/Litterature/ 2017-junior.pdf
Documents similaires
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/tCsZZ5QPWCG7DPjqg2GFzeVMkD2IbafXL8RCK1Ni60jAzJabmvT7CjoC5bKCoTphRJ30SR4h1gEuPgzrshuLGJM8.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/tEDvlryjGKCRtGqYcNLfZHFY4DaHR1td6kqUIoNN6iIPFKJfqeTuxviiqkUGtk5aWvdMXeKMVu1se9yZqIxmq0Ih.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/unywydGHDm2QN4pAXacrZ79RdxqDTFV7RUpv1yS69eCPAXHdF0bnpGNSnvkpoHR7HVFzVnBj4oLDKpZrYiJ4ipcP.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/c6M0SP91nLTz7qCdKaOYNr4ur65ogWJG0F8pzobfhZh417ghXKr2pZRHWWboo51dmq1t9WoXDlXQJRHsiaOl5OSm.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/caOAD3siinxf8KvIxTJx6Qfep2Z6g3kM0gzlXRMPTnfERn58Rt126mM1qO03noSjkRDn7Lx9PUfgyqFwJVo1uq8Y.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/mtEFf671xZaaJ71e39ISso7y7IQ5K4GxZCHrZCOuUaFYuwJCp79LVsSQIiJcGUh532zolckH5V8EzGYQQo8TLlNJ.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/sc35zXEvmo3lTK3nfeegi9Wau9tOiMmxtNyr8Ey7TwJaAdwUuiAp6c2bphS5rDAPd6HJwlD1sGONYXR4o6hspPCE.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/I69nH97dIaFFu5iNM64GaxHwXbKwKLJRAV8OIZNCeazTC2kGiEVNy6fFd3PimQOU76rT7j231NIpYMmGI0BufQcs.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/3eWCHevqWYjH7eSqJfgbH8OK2dMNb4QwDGjkqXVXHM82rzRwDVbXbRmOKcZQXZOCjqjSJ9emcYt3b7xciwzqVbCK.png)
![](https://b3c3.c12.e2-4.dev/disserty/uploads/preview/24wWQ8wKW26YBR6y93hVqVTl5uAto41QR0AgpvFdyUXTtyV9rS4KDpVs2I2HdBWihxGoO1fuacl5F1doCPYtxOaD.png)
-
25
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Sep 10, 2021
- Catégorie Literature / Litté...
- Langue French
- Taille du fichier 0.5151MB