Guest User

Untitled

a guest
May 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Picnic
  5.     {
  6.         //Students from 5th class decided to make a picnic. Each class had to buy something.
  7.         //And Teddy is dropped to provide soft drink. However,
  8.         //it is difficult for how to buy bottles of soda for all students,  
  9.         //if every child drink - 2 cups of 200 ml.
  10.         //Write a program piknik, which calculates how many bottles to buy Teddy
  11.  
  12.         //Input
  13.         //From the standard input is read three integers k, l and ml. k – number of students,
  14.         //l and lm – capacity of one bottle of soft drink.
  15.         //Exit
  16.         //The standard output displays one number - the number of bottles of soda that Teddy will buy.
  17.  
  18.         static void Main(string[] args)
  19.         {
  20.  
  21.             int k = int.Parse(Console.ReadLine());
  22.             int l = int.Parse(Console.ReadLine());
  23.             int ml = int.Parse(Console.ReadLine());
  24.  
  25.  
  26.             if(k < 1 || k > 26 || l > 20 || l < 0 || ml < 0 || ml > 1000){
  27.                 return;
  28.             }
  29.  
  30.             double val =  Convert.ToDouble(ml) / 1000;
  31.             val += Convert.ToDouble(l);
  32.  
  33.             double answer = 0;
  34.             answer = (Convert.ToDouble(k) * 0.4) / val;
  35.  
  36.             if (answer != Math.Round(answer))
  37.             {
  38.                 answer = Math.Floor(answer) + 1;
  39.             }
  40.  
  41.             Console.WriteLine(Convert.ToInt32(answer));
  42.    
  43.         }
  44.     }
Add Comment
Please, Sign In to add comment