Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from mc-cat-tty/lezione-4
Browse files Browse the repository at this point in the history
add esercizio
  • Loading branch information
mc-cat-tty authored Oct 5, 2021
2 parents e37a6a8 + bcbd85f commit 847c447
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Binary file added esercitazioni/a.out
Binary file not shown.
32 changes: 32 additions & 0 deletions esercitazioni/download_from_server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>

using namespace std;

int main() {
// [kb/s]
const int V1_MAX = 200, // if t <= 60 min
V1_MIN = 50, // if t > 60 min
V2 = 100; // always
const int V1_MAX_TIME_SECONDS = 60*60;
int dim; // dimensione film [kb]

cout << "Dimensione film [kb]: ";
cin >> dim;

int t_v1_max = dim/V1_MAX;
if (t_v1_max <= 60)
cout << "Server 1 in " << t_v1_max/60;
else {
int max_dim_v1_max = V1_MAX*V1_MAX_TIME_SECONDS;
int dim_v1_min = dim-max_dim_v1_max;
int t_v1_min = dim_v1_min/V1_MIN;
int t_v2 = dim/V2;
if (V1_MAX_TIME_SECONDS+t_v1_min <= t_v2)
cout << "Server 1 in " << (V1_MAX_TIME_SECONDS+t_v1_min)/60;
else
cout << "Server 2 in " << t_v2/60;
}
cout << endl;

return 0;
}

0 comments on commit 847c447

Please sign in to comment.