This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mc-cat-tty/lezione-4
add esercizio
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |