Es un problema simple en el que comenzamos con time = 0 y verificamos si podemos ver el video en el tiempo restante. Si no, incrementamos el tiempo y verificamos nuevamente. Aquí está el código.
#include
using namespace std;
int main()
{
long long t,x,y,z;
/*x - kB required to watch 1 second of the video
y - Download speed in kB/s
z - Duration of the video in seconds*/ scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld%lld",&x,&y,&z);
long long totaldata=x*z;
long long time=0,databuffered,datarequired;
//time is the time when we start watching video
databuffered=time*y;
datarequired=total data-databuffered;
// z*y is data that will buffer in z sec..
while(z*y < datarequired)
{
time++;
databuffered=time*y;
datarequired=totaldata-databuffered;
}
printf("%lld\n",time);
}
}
#include
using namespace std;
int main()
{
long long t,x,y,z;
/*x - kB required to watch 1 second of the video
y - Download speed in kB/s
z - Duration of the video in seconds*/ scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld%lld",&x,&y,&z);
long long totaldata=x*z;
long long time=0,databuffered,datarequired;
//time is the time when we start watching video
databuffered=time*y;
datarequired=total data-databuffered;
// z*y is data that will buffer in z sec..
while(z*y < datarequired)
{
time++;
databuffered=time*y;
datarequired=totaldata-databuffered;
}
printf("%lld\n",time);
}
}
- ¿Cuál es la forma más eficiente de clasificar 4 TB en una sola máquina con 4 GB de RAM?
- ¿Qué es el algoritmo de YouTube?
- ¿Cómo funciona el 'algoritmo tabula rasa' de AlphaGo Zero?
- Con los algoritmos de cifrado modernos, ¿es factible que alguien sepa qué algoritmo se utilizó al mirar el texto cifrado?
- ¿Qué es el algoritmo de Wagner y Fischer y cuál es su código de muestra en C ++?