#include <stdio.h> int main() { int n, sum = 0, temp; float d; scanf("%d", &n); while (n>0) { temp = (n-1) / 100000; switch (temp) { case 0:d = 0.1; break; case 1:d = 0.075; break; case 2: case 3:d = 0.05; break; case 4: case 5:d = 0.03; break; default:d = 0.01; break; } sum += (n - 100000 * temp)*d; n = 100000 * temp; } printf("%d", sum); } |
Double click to view unformatted code.