Advertisement
n4wn4w

1 zadacha

Mar 20th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 34.64 KB | None | 0 0
  1. // Read input data   /////////////// NAKOV
  2.         decimal X = decimal.Parse(Console.ReadLine());
  3.         decimal Y = decimal.Parse(Console.ReadLine());
  4.  
  5.         // Solve the problem
  6.         if (X == 0 && Y == 0)
  7.         {
  8.             Console.WriteLine(0);
  9.         }
  10.         else if (X == 0)
  11.         {
  12.             Console.WriteLine(5);
  13.         }
  14.         else if (Y == 0)
  15.         {
  16.             Console.WriteLine(6);
  17.         }
  18.         else if (X > 0 && Y > 0)
  19.         {
  20.             Console.WriteLine(1);
  21.         }
  22.         else if (X < 0 && Y > 0)
  23.         {
  24.             Console.WriteLine(2);
  25.         }
  26.         else if (X < 0 && Y < 0)
  27.         {
  28.             Console.WriteLine(3);
  29.         }
  30.         else // if (X > 0 && Y < 0)
  31.         {
  32.             Console.WriteLine(4);
  33.         }
  34.    
  35.  
  36. 1/////////////////////////////////////////////////////////////////////////kgkgkgkghkytueuywsr
  37.  
  38.         string year = Console.ReadLine();
  39.             double p = double.Parse(Console.ReadLine());
  40.             double h = double.Parse(Console.ReadLine());
  41.  
  42.             double allweekends = 52;
  43.             double normalweekends = (allweekends - h) * 2 / 3;
  44.             double totalholydays = p / 2;
  45.             double result = h + normalweekends + totalholydays;
  46.  
  47.             if (year == "t")
  48.             {
  49.                 result = result + 3;
  50.             }
  51.             result = Math.Floor(result);
  52.             Console.WriteLine(result);
  53.  
  54.  
  55.  
  56. 2//////////////////////////////////////////////////////////////////////////////////////////////////////////////
  57.  
  58.  
  59.             string year = Console.ReadLine();
  60.             double p = double.Parse(Console.ReadLine());// holydasy
  61.             double h = double.Parse(Console.ReadLine());// hometown
  62.             double allWeekEnds = 48;
  63.             double normalWeekEnds = (allWeekEnds - h) * 3 / 4;
  64.             double holidays = p * 2 / 3;
  65.             double result = h + normalWeekEnds + holidays;
  66.  
  67.             if (year == "leap")
  68.             {
  69.                 result = result + (result * 15 / 100);
  70.             }
  71.  
  72.             Console.WriteLine((int)result);
  73.            
  74.        
  75.  
  76.  
  77. 3 ///////////////////////////////////////////////////////////////////////////    
  78.             int projectHours = int.Parse(Console.ReadLine());
  79.             double days = double.Parse(Console.ReadLine());
  80.             double productivity = double.Parse(Console.ReadLine());
  81.  
  82.             double workHours = days - (days / 100 * 10);
  83.             workHours *= 12;
  84.             workHours *= productivity / 100;
  85.             workHours = Math.Floor(workHours);
  86.             int completeProjectHours = (int)(workHours - projectHours);
  87.  
  88.             if (completeProjectHours < 0)
  89.             {
  90.                 Console.WriteLine("No\n{0}", completeProjectHours);
  91.             }
  92.             else
  93.             {
  94.                 Console.WriteLine("Yes\n{0}", completeProjectHours);
  95.             }
  96.             //"Yes\n{0}"- \n e za nov red da pechata na sledvashtiqt red
  97.            
  98.    
  99.  
  100.  
  101. 4//////////////////////////////////////////////////////////////////////////////////////////////////
  102.            
  103.             string ticketType = Console.ReadLine();
  104.             int row = int.Parse(Console.ReadLine());
  105.             int col = int.Parse(Console.ReadLine());
  106.  
  107.             int ticketCount = row * col;
  108.             double ticketPrice = 0;
  109.  
  110.             switch (ticketType)
  111.             {
  112.                case "Premiere":
  113.                ticketPrice = 12.00;
  114.                break;
  115.  
  116.                case "Normal":
  117.                ticketPrice = 7.50;
  118.                break;
  119.                
  120.                 default:
  121.                ticketPrice = 5.00;
  122.                break;
  123.                
  124.             }
  125.  
  126.               double profit = ticketPrice * ticketCount;
  127.               Console.WriteLine("{0:F2} leva", profit);
  128.             }
  129.  
  130. 5//////////////////////////////////////////////////////////////////////////////////////////////
  131.  
  132.             int ax = int.Parse(Console.ReadLine());
  133.             int ay = int.Parse(Console.ReadLine());
  134.             int bx = int.Parse(Console.ReadLine());
  135.             int by = int.Parse(Console.ReadLine());
  136.             int cx = int.Parse(Console.ReadLine());
  137.             int cy = int.Parse(Console.ReadLine());
  138.  
  139.         double a = Math.Sqrt(Math.Pow((cx - bx),2)+Math.Pow((cy - by),2));
  140.         double b = Math.Sqrt(Math.Pow((cx - ax),2)+Math.Pow((cy - ay),2));
  141.         double c = Math.Sqrt(Math.Pow((bx - ax),2)+Math.Pow((by - ay),2));
  142.  
  143.             if(a + c > c && a + c > b && b + c > a)
  144.             {
  145.                double p = (a + b + c) / 2;
  146.                double area = Math.Sqrt(p*(p-a)*(p-b)*(p-c));
  147.                Console.WriteLine("Yes");
  148.                Console.WriteLine("{0:f2}", area);
  149.             }
  150.             else
  151.             {
  152.                Console.WriteLine("No");
  153.                c = Math.Round(c,2); // tova e dr variant da zakruglqm do 2 znam ako napisha 3 she go zakrugli do 3 znak
  154.  
  155.                Console.WriteLine("{0:0.00}", c);
  156.             }
  157.             }
  158.             // "{0:0.00}" za da izkara kogato ima 0 zashtoto kato go
  159.             // 0,00 kogato ima 0 zashtoto kato go slojim C i e 0
  160.             // trqbva da e 0,00 {"0:##"} za da vadi samo 00
  161.  
  162.  
  163.  
  164. 6/////////////////////////////////////////////////////////////////////////////////////////////////
  165.  
  166.             int startHour = int.Parse(Console.ReadLine());
  167.             int startMinutes = int.Parse(Console.ReadLine());
  168.             int startSeconds = int.Parse(Console.ReadLine());
  169.             string partOfDay = Console.ReadLine();
  170.             int duratationHour = int.Parse(Console.ReadLine());
  171.             int duratationMinutes = int.Parse(Console.ReadLine());
  172.             int duratationSeconds = int.Parse(Console.ReadLine());
  173.  
  174.             if (partOfDay == "PM")
  175.             {
  176.                 startHour += 12;
  177.  
  178.                 if (startHour == 24)
  179.                 {
  180.                     startHour = 0;
  181.                 }
  182.             }
  183.              // moi nachin s Add.Seconds
  184. DateTime startTime =
  185.  new DateTime(2014, 01, 01, startHour, startMinutes, startSeconds);
  186.  
  187.  DateTime endTime = startTime.AddHours(duratationHour).AddMinutes(duratationMinutes).AddSeconds(duratationSeconds);
  188.  
  189.             Console.WriteLine("{0:hh:mm:ss:tt}", endTime);
  190.  
  191.  
  192.  
  193.  
  194.  
  195. 7////////////////////////////////////////////////////////////////////////////////////////////////////////
  196.  
  197.             string dayofWeek = Console.ReadLine();
  198.             double sum = 0;
  199.  
  200.             for (int i = 0; i < 3; i++)
  201.             {
  202.                 double tempQuantity = double.Parse(Console.ReadLine());
  203.                 string temoProduct = Console.ReadLine();
  204.                 double price = 0;
  205.                 bool isFruit = false;
  206.                 bool vegeta = false;
  207.                
  208.  
  209.                 switch (temoProduct)
  210.                 {
  211.                     case "banana":
  212.                         {
  213.                             price = 1.80;
  214.                             isFruit = true;
  215.                         }
  216.                         break;
  217.                     case "cucumber":
  218.                         {
  219.                             price = 2.75;
  220.                             vegeta = true;
  221.                         }
  222.                         break;
  223.                     case "tomato":
  224.                         {
  225.                             price = 3.20;
  226.                             vegeta = true;
  227.                         }
  228.                         break;
  229.                     case "orange":
  230.                         {
  231.                             price = 1.60;
  232.                             isFruit = true;
  233.                         }
  234.                         break;
  235.                     case "apple":
  236.                         {
  237.                             price = 0.86;
  238.                             isFruit = true;
  239.                         }
  240.                         break;
  241.                 }
  242.   //// tuk smqtame cenata na produkta I kolichestvoto
  243.                 double value = price * tempQuantity;
  244.  
  245.                
  246.                     switch (dayofWeek)
  247.                     {
  248.                         case "Friday":
  249.                             {
  250.                                 value = 0.90 * value;
  251.                             }
  252.                             break;
  253.  
  254.                         case "Sunday":
  255.                 ////////// produljenie na FRUIT MARKET 7 variant    
  256.  
  257.                             {
  258.                                 value = 0.95 * value;
  259.                             }
  260.                             break;
  261.  
  262.                         case "Tuesday":
  263.                             {
  264.                                 if (isFruit == true)
  265.                                 {
  266.                                     value = 0.8 * value;
  267.                                 }
  268.                             }
  269.                             break;
  270.  
  271.                         case "Wednesday":
  272.                             {
  273.                                 if (vegeta == true) // moje i isFruit == false
  274.                               {
  275.                                    value = 0.9 * value;
  276.                                }
  277.                          ////   if (!isFruit) // moje i isFruit == false
  278.                         //  //   {
  279.                         // //      value = 0.9 * value;
  280.                         ////  }
  281.                             }
  282.                             break;
  283.  
  284.                         case "Thursday":
  285.                             {
  286.                                 if (temoProduct == "banana")
  287.                                 {
  288.                                     value = 0.70 * value;
  289.                                 }
  290.                             }
  291.                             break;
  292.  
  293.                     }
  294.                     //// i tuk subiram value ot razli4nite dni s namalenie i go vurtim 3 puti kolkoto e cikala za 3te produkta
  295.                    
  296.                     sum = sum + value;
  297.                 }
  298.                
  299.                 Console.WriteLine("{0:f2}", sum);
  300.         }
  301.  
  302.  
  303. 8////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  304.  
  305.  int h = int.Parse(Console.ReadLine());  /// h mi e size nafigurata primer 2 ili 15
  306.  
  307.             for (int i = 0; i < 5; i++)
  308.             {
  309.                 int x = int.Parse(Console.ReadLine());
  310.                 int y = int.Parse(Console.ReadLine());
  311.  
  312.                 bool box1 = ((x >= h && x <= 2 * h) && (y >= h && y <= 4 * h));
  313.                 bool box2 = ((x >= 0 && x <= 3 * h) && (y >= 0 && y <= h));
  314.  
  315.                 if (box1 || box2)
  316.                 {
  317.                     Console.WriteLine("inside");
  318.                 }
  319.                 else
  320.                 {
  321.                     Console.WriteLine("outside");
  322.                 }
  323.                 // dr izpisvane bez  bool promenlivi
  324.                 // probvah s 2 IF no nqma kaka da s epolu4i taka zashtoto
  325.                 // figurata ne e cqla i mi izpisva po 2 puti inside ili outside
  326.                
  327.               /*  if (((x >= h && x <= 2 * h) && (y >= h && y <= 4 * h)) ||
  328.                ((x >= 0 && x <= 3 * h) && (y >= 0 && y <= h)))
  329.                 {
  330.                     Console.WriteLine("inside");
  331.                 }
  332.                 else
  333.                 {
  334.                     Console.WriteLine("outside");
  335.                 } */
  336.             }
  337.             ///////////////////////
  338.             // moje i 3 variant 5 if / else kato proverqvame za vsqko edno
  339.             // primerno x1 polse za x2 i taka do x5
  340.             /*    int h = int.Parse(Console.ReadLine());
  341.  
  342.                 int x1 = int.Parse(Console.ReadLine());
  343.                 int y1 = int.Parse(Console.ReadLine());
  344.  
  345.                if (((x1 >= h && x1 <= 2 * h) && (y1 >= h && y1 <= 4 * h)) ||
  346.                ((x1 >= 0 && x1 <= 3 * h) && (y1 >= 0 && y1 <=h)))
  347.                 {
  348.                     Console.WriteLine("inside");
  349.                 }
  350.                 else
  351.                 {
  352.                     Console.WriteLine("outside");
  353.                 }
  354.  
  355.                 int x2 = int.Parse(Console.ReadLine());
  356.                 int y2 = int.Parse(Console.ReadLine());
  357.  
  358.                 if (((x2 >= h && x2 <= 2 * h) && (y2 >= h && y2 <= 4 * h)) ||
  359.                    ((x2 >= 0 && x2 <= 3 * h) && (y2 >= 0 && y2 <= h)))
  360.                 {
  361.                     ///////// PRODULJENIE NA 8 variant
  362.  
  363.                     Console.WriteLine("inside");
  364.                 }
  365.                 else
  366.                 {
  367.                     Console.WriteLine("outside");
  368.                 }
  369.  
  370.                 int x3 = int.Parse(Console.ReadLine());
  371.                 int y3 = int.Parse(Console.ReadLine());
  372.  
  373.                 if (((x3 >= h && x3 <= 2 * h) && (y3 >= h && y3 <= 4 * h)) ||
  374.                    ((x3 >= 0 && x3 <= 3 * h) && (y3 >= 0 && y3 <= h)))
  375.                 {
  376.                     Console.WriteLine("inside");
  377.                 }
  378.                 else
  379.                 {
  380.                     Console.WriteLine("outside");
  381.                 }
  382.  
  383.                 int x4 = int.Parse(Console.ReadLine());
  384.                 int y4 = int.Parse(Console.ReadLine());
  385.  
  386.                 if (((x4 >= h && x4 <= 2 * h) && (y4 >= h && y4 <= 4 * h)) ||
  387.                    ((x4 >= 0 && x4 <= 3 * h) && (y4 >= 0 && y4 <= h)))
  388.                 {
  389.                     Console.WriteLine("inside");
  390.                 }
  391.                 else
  392.                 {
  393.                     Console.WriteLine("outside");
  394.                 }
  395.  
  396.  
  397.                 int x5 = int.Parse(Console.ReadLine());
  398.                 int y5 = int.Parse(Console.ReadLine());
  399.  
  400.                 if (((x5 >= h && x5 <= 2 * h) && (y5 >= h && y5 <= 4 * h)) ||
  401.                    ((x5 >= 0 && x5 <= 3 * h) && (y5 >= 0 && y5 <= h)))
  402.                 {
  403.                     Console.WriteLine("inside");
  404.                 }
  405.                 else
  406.                 {
  407.                     Console.WriteLine("outside");
  408.                 }
  409.  
  410.                     */
  411.  
  412.             }
  413.            
  414.  
  415. FIT IN BOX 28 APRIL ////////////////////////////////////////////////////////////////////////////////
  416.           int w1 = int.Parse(Console.ReadLine());
  417.             int h1 = int.Parse(Console.ReadLine());
  418.             int d1 = int.Parse(Console.ReadLine());
  419.  
  420.             int w2 = int.Parse(Console.ReadLine());
  421.             int h2 = int.Parse(Console.ReadLine());
  422.             int d2 = int.Parse(Console.ReadLine());
  423.  
  424.             if (w1 < w2 && h1 < h2 && d1 < d2)
  425.             {
  426.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, h2, d2);
  427.             }
  428.             if (w1 < w2 && h1 < d2 && d1 < h2)
  429.             {
  430. Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, w2, d2, h2);
  431.             }
  432.             if (w1 < h2 && h1 < w2 && w1 < d2)
  433.             {
  434.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, w2, d2);
  435.             }
  436.             if (w1 < h2 && h1 < d2 && d1 < w2)
  437.             {
  438.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, h2, d2, w2);
  439.             }
  440.             if (w1 < d2 && h1 < w2 && d1 < h2)
  441.             {
  442.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, w2, h2);
  443.             }
  444.             if (w1 < d2 && h1 < h2 && d1 < w2)
  445.             {
  446.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w1, h1, d1, d2, h2, w2);
  447.             }
  448.             // vtora kutiq vurtene /////////////////////////////////////////////////////////////////
  449.             if (w1 > w2 && h1 > h2 && d1 > d2)
  450.             {
  451.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, w1, h1, d1);
  452.             }
  453.             if (w1 > w2 && h1 > d2 && d1 > h2)
  454.             {
  455.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, w1, d1, h1);
  456.             }
  457.             if (w1 > h2 && h1 > w2 && d1 > d2)
  458.             {
  459.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, h1, w1, d1);
  460.             }
  461.             if (w1 > h2 && h1 > d2 && d1 > w2)
  462.             {
  463.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, h1, d1, w1);
  464.             }
  465.             if (w1 > d2 && h1 > w2 && d1 > h2)
  466.             {
  467.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, d1, w1, h1);
  468.             }
  469.             if (w1 > d2 && h1 > h2 && d1 > w2)
  470.             {
  471.  Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})", w2, h2, d2, d1, h1, w1);
  472.             }
  473. FIT IN BOX    2ri variant za reshenie avtorsko reshenie ////////////////////////////////////////////////////////////
  474.       ///s metod
  475.    int w1 = int.Parse(Console.ReadLine());
  476.         int h1 = int.Parse(Console.ReadLine());
  477.         int d1 = int.Parse(Console.ReadLine());
  478.  
  479.         int w2 = int.Parse(Console.ReadLine());
  480.         int h2 = int.Parse(Console.ReadLine());
  481.         int d2 = int.Parse(Console.ReadLine());
  482.  
  483.         // Try to fit the first box inside the second box (6 possibilities)
  484.         CheckBoxes(w1, h1, d1, w2, h2, d2);
  485.         CheckBoxes(w1, h1, d1, w2, d2, h2);
  486.         CheckBoxes(w1, h1, d1, h2, w2, d2);
  487.         CheckBoxes(w1, h1, d1, h2, d2, w2);
  488.         CheckBoxes(w1, h1, d1, d2, w2, h2);
  489.         CheckBoxes(w1, h1, d1, d2, h2, w2);
  490.  
  491.         // Try to fit the second box inside the first box (6 possibilities)
  492.         CheckBoxes(w2, h2, d2, w1, h1, d1);
  493.         CheckBoxes(w2, h2, d2, w1, d1, h1);
  494.         CheckBoxes(w2, h2, d2, h1, w1, d1);
  495.         CheckBoxes(w2, h2, d2, h1, d1, w1);
  496.         CheckBoxes(w2, h2, d2, d1, w1, h1);
  497.         CheckBoxes(w2, h2, d2, d1, h1, w1);
  498.     }
  499.  
  500.     private static void CheckBoxes(
  501.         int firstWidth, int firstHeight, int firstDepth,
  502.         int secondWidth, int secondHeight, int secondDepth)
  503.     {
  504.         if (firstWidth < secondWidth && firstHeight < secondHeight && firstDepth < secondDepth)
  505.         {
  506.             Console.WriteLine("({0}, {1}, {2}) < ({3}, {4}, {5})",
  507.                 firstWidth, firstHeight, firstDepth, secondWidth, secondHeight, secondDepth);
  508.         }
  509.        
  510.  
  511.  
  512.  
  513.  
  514.  
  515. 25 july morning /////////////////////////////////////   ////////////// 
  516.         int startDayOfWeek = int.Parse(Console.ReadLine());
  517.             int daysEating = int.Parse(Console.ReadLine());
  518.             int melons = 0;
  519.             int watermelons = 0;
  520.             for (int i = startDayOfWeek; i < daysEating + startDayOfWeek; i++)
  521.             {
  522.       int dayOfWeek = i % 7;// delim i % 7 naprimer 3 % 7= 3 za da vleze v 3 den
  523.                 // 7 % 7 = 0
  524.                 // i sushto mi pravi Case ot 0 do 6 i ne moje  ako sloja
  525.                 //(naprimer  case 9 ne mi go za4ita zaduljitelno case ot 0 do 6)
  526.                 //i zatova v  primera  5 den ot sedmicata i 6 dena qdene
  527.                 //mi vurti i 0 koqto v primera ne e izpisana
  528.                 switch (dayOfWeek)
  529.                 {
  530.                    ///* case 0:
  531.                          watermelons += 6;
  532.                          melons += 2;
  533.                          break; *///
  534.                     case 1:
  535.                         watermelons += 1;
  536.                         break;
  537.                     case 2:
  538.                         melons += 2;
  539.                         break;
  540.                     case 3:
  541.                         watermelons += 1;
  542.                         melons += 1;
  543.                         break;
  544.                     case 4:
  545.                         watermelons += 2;
  546.                         break;
  547.                     case 5:
  548.                         melons += 2;
  549.                         watermelons += 2;
  550.                         break;
  551.                     case 6:
  552.                         watermelons += 1;
  553.                         melons += 2;
  554.                         break;
  555.  
  556.                     default:
  557.                         break;
  558.                  }
  559.             }
  560.     // moje i bez promenlivata diff a prosoto da si gi zapishem v if elsa
  561.     // zaduljitelno go pravq polojitelno s Math.Abs//
  562.             int diff = Math.Abs(melons - watermelons);
  563.             if (melons > watermelons)
  564.             {
  565.                 //moje bez diff a samo stoinosta na melons
  566.                 Console.WriteLine("{0} more melons", diff);
  567.             }
  568.             else if (watermelons > melons)
  569.             {
  570.                 // moje bez diff a samo sotista na watermelons
  571.                 Console.WriteLine("{0} more watermelons ", diff);
  572.             }
  573.             else
  574.             {
  575.                 Console.WriteLine("Equal amount: {0}", melons);
  576.  
  577.  
  578.  
  579.  
  580.  
  581. 25 july evening  Electricity ///////////////////////////////////////////////////////////////////// 
  582.          //input
  583.             int numberOfFloors = int.Parse(Console.ReadLine());
  584.             int flatsPerFloor = int.Parse(Console.ReadLine());
  585.             DateTime time = DateTime.Parse(Console.ReadLine());
  586.             // stoinosti za reingja/range  na time
  587.             DateTime firstStart = DateTime.Parse("00:00");
  588.             DateTime firstEnd = DateTime.Parse("08:59");
  589.             DateTime secondStart = DateTime.Parse("14:00");
  590.             DateTime secondEnd = DateTime.Parse("18:59");
  591.             DateTime thirdStart = DateTime.Parse("19:00");
  592.             DateTime thirdEnd = DateTime.Parse("23:59");
  593.            
  594.             double lampPower = 100.53;
  595.             double compPower = 125.90;
  596.  
  597.             double totalPower = 0;
  598.              // if za raztoqnieto ot vreme dali suvpada
  599.             if (firstStart <= time && time <= firstEnd)
  600.             {
  601.                 totalPower = totalPower + ((lampPower * 1) + (compPower * 8));
  602.             }
  603.             else if (secondStart <= time && time <= secondEnd)
  604.             {
  605.                 totalPower = totalPower + ((lampPower * 2) + (compPower * 2));
  606.             }
  607.             else if (thirdStart <= time && time <= thirdEnd)
  608.             {
  609.                 totalPower = totalPower + ((lampPower * 7) + (compPower * 6));
  610.             }
  611.             totalPower = totalPower *(numberOfFloors * flatsPerFloor);
  612.             /// output
  613.             Console.WriteLine("{0} Watts", (int)(totalPower));
  614.  
  615. /////////////////////////////////////////////vtoro reshenie avtorsko /*
  616. int floors = int.Parse(Console.ReadLine());
  617.         int flats = int.Parse(Console.ReadLine());
  618.         DateTime time = DateTime.Parse(Console.ReadLine());
  619.  
  620.         int sumWats;
  621.         if (time.Hour >= 14 && time.Hour <= 18)
  622.         {
  623.             // Noon time
  624.             double noonConsumption = (2 * 100.53) + (2 * 125.90);
  625.             sumWats = (int)(noonConsumption * flats * floors);
  626.         }
  627.         else if (time.Hour >= 19 && time.Hour <= 23)
  628.         {
  629.             // Afternoon time
  630.             double afternoonConsumption = (7 * 100.53) + (6 * 125.90);
  631.             sumWats = (int)(afternoonConsumption * flats * floors);
  632.         }
  633.         else if (time.Hour >= 0 && time.Hour <= 8)
  634.         {
  635.             // Midnight time
  636.             double midnightConsumption = (1 * 100.53) + (8 * 125.90);
  637.             sumWats = (int)(midnightConsumption * flats * floors);
  638.         }  */
  639.        
  640.        Console.WriteLine(sumWats + " Watts");
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647. 22 avgust TABLES//////////////////////////////////////////////////////////////////////////
  648. long budle1 = long.Parse(Console.ReadLine());              
  649. long budle2 = long.Parse(Console.ReadLine());              
  650. long budle3 = long.Parse(Console.ReadLine());              
  651. long budle4 = long.Parse(Console.ReadLine());              
  652. long tableTops = long.Parse(Console.ReadLine            
  653. long tablesToBeMade = long.Parse(Console.ReadLine());
  654.  
  655. long allLegs = (budle1 * 1) + (budle2 * 2) + (budle3 * 3) + (budle4 * 4);
  656. long tablesPossible = Math.Min(allLegs / 4 , tableTops);
  657.            
  658.             if (tablesPossible == tablesToBeMade)
  659.             {
  660.                 Console.WriteLine("Just enough tables made: {0}", tablesToBeMade);
  661.             }
  662.             else if (tablesPossible > tablesToBeMade)
  663.             {
  664. Console.WriteLine("more: {0} ",
  665.                 tablesPossible - tablesToBeMade < 0 ? 0 : tablesPossible - tablesToBeMade);
  666.            ///////Math.Max(0,tablesPossible - tablesToBeMade));
  667.                 Console.WriteLine("tops left: {0}, legs left: {1}",
  668.                     Math.Max(0,tablesPossible - tablesToBeMade),
  669.                     Math.Max(0,allLegs - tablesToBeMade*4) );
  670.                 // ili legs - n*4 zashtoto vinagi shte e polojitelno 4islo
  671.             }
  672. //******************************************************************
  673.             else /////////moje I -> if (tablesToBeMade > tablesPossible)
  674.             {
  675.                 Console.WriteLine("less: {0} ",
  676.                tablesPossible - tablesToBeMade > 0 ? 0 : tablesPossible - tablesToBeMade);
  677.          // ili da go izpisva taka edno i sushto e Console.WriteLine("less: {0} ",Math.Min(0, tablesPossible - tablesToBeMade));
  678.  
  679.                 // poneje e 0 ili otricatelno nqma kak da imamme less polojitelni + masi
  680.  
  681.                 //*******************************************
  682.                 Console.WriteLine("tops needed: {0}, legs needed: {1}",
  683.                     Math.Max(0, tablesToBeMade - tablesPossible),
  684.                     Math.Max(0, tablesToBeMade * 4 - allLegs));
  685.                 // legs needed mi trqbva vinagi 0 ili polojitelno chislo i kogato legs sa mi minus nqma kak da izpisha -2 lega
  686.       // N * 4 - legs < 0 ? 0 : N * 4 - legs
  687.       // ternaren operator koito ako e otricatelno da mi izpisva 0                                                                                                            
  688.       //poneje legs sa mi pove4e ot kolkoto imam nujda i nqmam needed -2                                                                                                              
  689.       //i ako e polojitelno da mi izpisva razlikata poneje need mi e pove4e
  690.             }
  691.         }
  692. ////Math.Min zima po-malkoto ot 2 4isla ako e
  693. //Math.Min(0, tablesPossible - tablesToBeMade)
  694.  //   vrushta 0 ili otricatelno chislo
  695. // Math.Max vrushta po-golqmata ot 2 sotinosti
  696. // ako e Math.Max(0, tablesToBeMade * 4 - allLegs));
  697. // za da mi vrushta 0 ili polojitelno chislo
  698.  
  699.  
  700.  
  701. ////TABLES MOE VTORO RESHENIE  bez  Matn>min I Math.MAX ////////////////////////
  702.        
  703.         long budle1 = long.Parse(Console.ReadLine());
  704.             long budle2 = long.Parse(Console.ReadLine());
  705.             long budle3 = long.Parse(Console.ReadLine());
  706.             long budle4 = long.Parse(Console.ReadLine());
  707.             long T = long.Parse(Console.ReadLine());
  708.             long N = long.Parse(Console.ReadLine());
  709.  
  710.           long legs = (budle1 * 1) + (budle2 * 2) + (budle3 * 3) + (budle4 * 4);
  711.             long legsLeft = legs - (T * 4);
  712.             long legsPosaibleTables = legs / 4;
  713.             long posibleTables = Math.Abs(legsPosaibleTables - T);
  714.  
  715.             if (legsPosaibleTables > T)
  716.             {
  717.                 posibleTables = legsPosaibleTables - posibleTables;
  718.             }
  719.  
  720.             else if (T > legsPosaibleTables)
  721.             {
  722.                 posibleTables = T - posibleTables;
  723.             }
  724.             else
  725.             {
  726.                 posibleTables = T;
  727.             }
  728.  
  729.             long tablesNeed = posibleTables - N;
  730.             long legsneed = legs- N *4;
  731.             long topsneed = T - N;
  732.  
  733.             if (tablesNeed == 0)
  734.             {
  735.                 Console.WriteLine("Just enough tables made: {0}", N);
  736.             }
  737.             else if (posibleTables > N)
  738.             {
  739.                 Console.WriteLine("more: {0} ", Math.Abs(tablesNeed));
  740.                 Console.WriteLine("tops left: {0}, legs left: {1}", topsneed, Math.Abs(legsneed));// ili legs - n*4 zashtoto vinagi trqbva da e polojitelno 4islo
  741.             }
  742.             else // if (need > posibleTables)
  743.             {
  744.                 Console.WriteLine("less: {0} ", tablesNeed);
  745.                 Console.WriteLine("tops needed: {0}, legs needed: {1}", Math.Abs(topsneed), N * 4 - legs < 0 ? 0 : N * 4 - legs);
  746.            // ternaren operator koito ako e otricatelno da mi izpisva 0                                                                                                            
  747.            //poneje legs sa mi pove4e ot kolkoto imam nujda i nqmam needed -2                                                                                                              
  748.            //i ako e polojitelno da mi izpisva razlikata poneje need mi e pove4e
  749.             }
  750.            
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758. 26 avgust  TIC TAE TOE ////////////////////////////////////////////////////////////////////////////
  759.            
  760.            
  761.             int x = int.Parse(Console.ReadLine());
  762.             int y = int.Parse(Console.ReadLine());
  763.             int value = int.Parse(Console.ReadLine());
  764.             int position = 0;
  765.  
  766.             if(y==0 && x==0)
  767.             {
  768.                 position = 1;
  769.             }
  770.             if (y == 0 && x == 1)
  771.             {
  772.                 position = 2;
  773.             }
  774.             if (y == 0 && x == 2)
  775.             {
  776.                 position = 3;
  777.             }
  778.             if (y == 1 && x == 0)
  779.             {
  780.                 position = 4;
  781.             }
  782.             if (y == 1 && x == 1)
  783.             {
  784.                 position = 5;
  785.             }
  786.             if (y == 1 && x == 2)
  787.             {
  788.                 position = 6;
  789.             }
  790.             if (y == 2 && x == 0)
  791.             {
  792.                 position = 7;
  793.             }
  794.             if (y == 2 && x == 1)
  795.             {
  796.                 position = 8;
  797.             }
  798.             if (y == 2 && x == 2)
  799.             {
  800.                 position = 9;
  801.             }
  802.  
  803.             value = (value + position) - 1;
  804.             // -1 zashtoto indeksa mi nadvishava stoinostta s 1
  805.             // poneje 4isloto ot koeto trugvame e 10 position mi e 5 stava 15  ana men mi trqbva chisloto pod tazi pozicia koeto e 14 zatova vadim -1 i value mi stava 14
  806.             Console.WriteLine((long)Math.Pow(value,position));// value po stepenta 14  na 5 stepen s math.pow
  807.             // Math.Pow stoinosta i  stepen koeto  v primera  e 14 na 5 stepen
  808.         }
  809.        
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818. 7 Noemvri BUDGET //////////////////////////////////////////////////////////////////////////
  819.        
  820.        
  821.          long money = long.Parse(Console.ReadLine());
  822.             long weekdaysGoingOut = long.Parse(Console.ReadLine());
  823.             long hometownWeekends = long.Parse(Console.ReadLine());
  824.  
  825.             long normalWeekdays = 22 - weekdaysGoingOut;
  826.             long totalWeekendsDays = 8;
  827.  
  828.             totalWeekendsDays -= (hometownWeekends * 2);
  829.  
  830.             // 10 * ((3% of 800) + 10)
  831.             long moneySpent = normalWeekdays * 10;
  832.             moneySpent += weekdaysGoingOut * ((((long)3 * money) / 100) + 10);
  833.             moneySpent += 150;
  834.             moneySpent += totalWeekendsDays * 20;
  835.  
  836.             long moneyLeft = money - moneySpent;
  837.             if (moneyLeft > 0)
  838.             {
  839.                 Console.WriteLine("Yes, leftover {0}.", moneyLeft);
  840.             }
  841.             else if (moneyLeft < 0)
  842.             {
  843.                 Console.WriteLine("No, not enough {0}.", Math.Abs(moneyLeft));
  844.             }
  845.             else
  846.             {
  847.                 Console.WriteLine("Exact Budget.");
  848.             }
  849.        
  850.        
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877. 8 noemvri BABA TINCHE AIRLINES //////////////////////////////////////////////////////////////////
  878.        
  879.        
  880.        // nachi za 4etene na nqkolko stoinosti ot edin red ReadLine
  881.             string[] firstClassInfo = Console.ReadLine().Split();
  882.             int firstClassPassengers = int.Parse(firstClassInfo[0]);
  883.             int firstClassFrequent = int.Parse(firstClassInfo[1]);
  884.             int firstClassMeals = int.Parse(firstClassInfo[2]);
  885.  
  886.             string[] secondClassInfo = Console.ReadLine().Split();
  887.             int secondClassPassengers = int.Parse(secondClassInfo[0]);
  888.             int secondClassFrequent = int.Parse(secondClassInfo[1]);
  889.             int secondClassMeals = int.Parse(secondClassInfo[2]);
  890.  
  891.             string[] thirdClassInfo = Console.ReadLine().Split();
  892.             int thirdClassPassengers = int.Parse(thirdClassInfo[0]);
  893.             int thirdClassFrequent = int.Parse(thirdClassInfo[1]);
  894.             int thirdClassMeals = int.Parse(thirdClassInfo[2]);
  895.  
  896.             int maxIncome = 233160;// maksimalnata pe4alba na baba tinche
  897.  
  898.             decimal income = 0m;
  899.  
  900.             income += (firstClassPassengers - firstClassFrequent) * 7000;
  901.             income += firstClassFrequent * 7000 * 0.3m;
  902.             income += firstClassMeals * 7000 * 0.005m;
  903.  
  904.             income += (secondClassPassengers - secondClassFrequent) * 3500;
  905.             income += secondClassFrequent * 3500 * 0.3m;
  906.             income += secondClassMeals * 3500 * 0.005m;
  907.  
  908.             income += (thirdClassPassengers - thirdClassFrequent) * 1000;
  909.             income += thirdClassFrequent * 1000 * 0.3m;
  910.             income += thirdClassMeals * 1000 * 0.005m;
  911.  
  912.          //income = (int)income;// preobrazuvame cqlta stoinost v int a ne samo
  913.  
  914.             // ot 1 red ili 2 na Console.WriteLine
  915.             Console.WriteLine((int)(income));
  916.             Console.WriteLine(maxIncome - (int)income);
  917.         }
  918.        
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936. 19 dekemvri TravelerBOB//////////////////////////////////////////////////////////
  937.        
  938.      //Reading input from the Console
  939.             string year = Console.ReadLine();
  940.             int contract = int.Parse(Console.ReadLine());
  941.             int family = int.Parse(Console.ReadLine());
  942.             //Calculating total travels for each type of month
  943.             int contractTravels = contract * (4 * 3);
  944.             int familyTravels = (2 * 2) * family;
  945.        // double normalTravels = (((12 - contract - family) * 12) * 3 / 5.0);
  946.             double normalTravels = 12 - contract - family;
  947.             normalTravels = normalTravels * 12;
  948.             normalTravels = normalTravels * 3 / 5.0;
  949.  
  950.             double totalTravels = contractTravels + familyTravels + normalTravels;
  951.  
  952.             //If the year is leap, 5% in addition
  953.             if (year == "leap")
  954.             {
  955.                 //totalTravels = totalTravels * 1.05;
  956.                 double procent = totalTravels * 5 / 100;
  957.                 totalTravels = totalTravels + procent;
  958.             }
  959.             //Printing the result
  960.             Console.WriteLine((int)totalTravels);
  961.            
  962.  
  963.  
  964.  
  965.  
  966.  
  967. 20 dekemvri  TANK ////////////////////////////////////////////////////////////////////////
  968.            
  969.            
  970.              int price = int.Parse(Console.ReadLine());
  971.             int partyDays = int.Parse(Console.ReadLine());
  972.      
  973.             int normalDays = 30 - partyDays;
  974.  
  975.             int monthlySavings = normalDays * 2;
  976.             int monthlyExpenses = partyDays * 5;
  977.             int monthlyBalance = monthlySavings - monthlyExpenses;
  978.  
  979.             double totalMonthsRequired = (double)price / monthlyBalance;
  980.            /* int result = (int)Math.Ceiling(totalMonthsRequired);
  981.             int years = result / 12;
  982.             int months = result % 12; */
  983.         // Math.Ceiling zakruglq do po-gornoto 4islo primer 2.1 go zakruglq na 3
  984.        
  985. // i zashto delim result % 12 nz
  986. // mesecite zakruglqm na gore ot 410.2307 na 411
  987. // za da moje kato gi razdelim 411 % 12 da mi izkara 3  ne 2 kakto pri 410
  988.            
  989.             double result = Math.Ceiling(totalMonthsRequired);
  990.             int intResulr = (int)(result);                    
  991.             int years = intResulr / 12;
  992.             int months = intResulr % 12;
  993.            
  994.          if (monthlyExpenses > monthlySavings )
  995.          {
  996.              Console.WriteLine("never");
  997.          }
  998.          else
  999.          {
  1000.             Console.WriteLine("{0} years, {1} months", years, months);
  1001.          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement