View Code of Problem 70

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		cout << fixed << setprecision(0);
		if (n <= 100000)cout << floor( n / 10);
		else if (n <= 200000)cout << floor( 10000 + (n - 10000)*0.075);
		else if (n <= 400000)cout << floor(10000 + 100000 * 0.075 + (n - 200000)*0.05);
		else if (n <= 600000)cout << floor(10000 + 100000 * 0.075 + 200000 * 0.05 + (n - 400000)*0.03);
		else if (n <= 1000000)cout << floor(10000 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (n - 600000)*0.015);
		else cout << floor(10000 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.015 + (n - 1000000)*0.01);
		cout << endl;
	}
}
/*
Main.cc: In function 'int main()':
Main.cc:8:20: error: 'setprecision' was not declared in this scope
   cout << fixed << setprecision(0);
                    ^~~~~~~~~~~~
*/

Double click to view unformatted code.


Back to problem 70