+ 2
The task "Duct Tape"
Hello world! I have a question for those who solved the problem called "Duct Tape". I still can't understand why all but one of the calculations are converted into inches. Namely, the length of the tape remains in feet, and everything else is converted into inches. Shouldn't everything be translated into inches? https://sololearn.com/compiler-playground/c2Os3PW5wGuZ/?ref=app
3 Respuestas
+ 10
AntireZ
uint height = Convert.ToUInt32(Console.ReadLine());
uint width = Convert.ToUInt32(Console.ReadLine());
uint roll = 60 * 2;
double squareDoor = (height*12*width*12);
uint answer = (uint)Math.Ceiling(squareDoor / roll);
Console.Write(answer);
Based on the rewrite if you have a 6 foot tall door 3 foot wide it would take approximately 22 rolls or 21 rolls and 2/3rds of number 22 roll.
+ 5
you can also use double instead of uint32 for the width and height and simplify the equation from:
(12 * w * 12 * h) / (60 * 2)
to:
w * h / 5
The C# code:
using System;
var w = Convert.ToDouble(Console.ReadLine())
;
var h = Convert.ToDouble(Console.ReadLine());
Console.Write(Math.Ceiling(w * h / 5));
+ 2
I found the answer, it was a matter of reducing the numbers.
The first formula is complete, the rest are abbreviated.
" double squareDoor = (height*12*width*12)*2;
uint squareDuctTape = (60*12) * 2;
double squareDoor = (height * width * 12) * 2;
uint squareDuctTape = 60*2;
double squareDoor = height * width *12;
uint squareDuctTape = 60;
double squareDoor = height * width;
uint squareDuctTape = 5; "