Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2019
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.13 KB | None | 0 0
  1. /*Tony and Andi love playing in the snow and having snowball
  2.  fights, but they always argue who makes the best snowballs.
  3.  They have decided to involve you in their fray, by making
  4.  you write a program which calculates snowball data, and
  5.  outputs the best snowball value.
  6.  
  7. You will receive N – an integer, the number of snowballs
  8. being made by Tony and Andi.
  9. For each snowball you will receive 3 input lines:
  10.     • On the first line you will get the
  11.     snowballSnow – an integer.
  12.     • On the second line you will get the
  13.     snowballTime – an integer.
  14.     • On the third line you will get the
  15.     snowballQuality – an integer.
  16. For each snowball you must calculate its
  17. snowballValue by the following formula:
  18. (snowballSnow / snowballTime) ^ snowballQuality
  19. At the end you must print the highest calculated
  20. snowballValue.
  21.  
  22. Input
  23.     • On the first input line you will receive N –
  24.     the number of snowballs.
  25.     • On the next N * 3 input lines you will be receiving
  26.     data about snowballs.
  27. Output
  28.     • As output you must print the highest calculated
  29.     snowballValue, by the formula, specified above.
  30.     • The output format is:
  31. {snowballSnow} : {snowballTime} = {snowballValue} ({snowballQuality})
  32.  
  33. Constraints:
  34.     • The number of snowballs (N) will be an integer in
  35.     range [0, 100].
  36.     • The snowballSnow is an integer in range [0, 1000].
  37.     • The snowballTime is an integer in range [1, 500].
  38.     • The snowballQuality is an integer in range [0, 100].
  39.     • Allowed working time / memory: 100ms / 16MB.
  40. _________________________________________________________
  41. Input                            Output
  42. 2                            10 : 2 = 125 (3)
  43. 10
  44. 2
  45. 3
  46. 5
  47. 5
  48. 5
  49. _________________________________________________________
  50. 3                            10 : 5 = 128 (7)
  51. 10
  52. 5
  53. 7
  54. 16
  55. 4
  56. 2
  57. 20
  58. 2
  59. 2
  60. _________________________________________________________
  61. */
  62. using System;
  63. using System.Numerics;
  64.  
  65. namespace _11Snowballs
  66. {
  67.     class Program
  68.     {
  69.         static void Main(string[] args)
  70.         {
  71.             int numberSnowballs = int.Parse(Console.ReadLine());
  72.             BigInteger bestValue = 0;
  73.             int bestSnow = 0;
  74.             int bestTime = 0;
  75.             int bestQuality = 0;
  76.             for (int i = 0; i < numberSnowballs; i++)
  77.             {
  78.                 int snowballSnow = int.Parse(Console.ReadLine());
  79.                 int snowballTime = int.Parse(Console.ReadLine());
  80.                 int snowballQuality = int.Parse(Console.ReadLine());
  81.                 if (snowballTime > 0)
  82.                 {
  83.                     BigInteger snowballValue = BigInteger.Pow(snowballSnow / snowballTime, snowballQuality);
  84.                     if (bestValue <= snowballValue)
  85.                     {
  86.                         bestSnow = snowballSnow;
  87.                         bestTime = snowballTime;
  88.                         bestQuality = snowballQuality;
  89.                         bestValue = snowballValue;
  90.                     }
  91.                 }
  92.             }
  93.             Console.WriteLine($"{bestSnow} : {bestTime} = {bestValue} ({bestQuality})");
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement