some programs!
This commit is contained in:
1 parent
5d30e847c1
commit
ed054247d5
32 files changed
+1882
-149
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
double get_price(int spent_money, int distance) {
|
||||
double price = 0;
|
||||
if (distance <= 6) {
|
||||
price = 3;
|
||||
} else {
|
||||
price = 4;
|
||||
}
|
||||
distance -= 12;
|
||||
if (distance > 0 && distance <= 32 - 12) { price += ceil(distance / 10.0); }
|
||||
distance -= 32 - 12;
|
||||
if (distance > 0) { price += ceil(distance / 20.0); }
|
||||
if (spent_money >= 400) { return price; }
|
||||
if (spent_money >= 150) { return price * 0.5; }
|
||||
if (spent_money >= 100) { return price * 0.8; }
|
||||
return price;
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int spent_money, distance;
|
||||
cin >> spent_money >> distance;
|
||||
cout << fixed << setprecision(2) << get_price(spent_money, distance) << endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user