fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long N, P;
  7. cin >> N >> P;
  8. double h, l, d, lenta, price;
  9. h = (1+N)*N*0.5;
  10. l = 0.5 + N*0.5;
  11. d = sqrt(h*h + l*l);
  12. lenta = ceil(d + d + 1);
  13. price = lenta * P;
  14. if (price >= 1000) {
  15. price *= 85;
  16. }
  17. else if (price >= 100) {
  18. price *= 90;
  19. }
  20. else {
  21. price *=100;
  22. }
  23. if (ceil(100./P) > lenta and price > 90*ceil(100./P)*P){
  24. price = 90*ceil(100./P)*P;
  25. }
  26. else if (ceil(1000./P) > lenta and price > 85*ceil(1000./P)*P) {
  27. price = 85*ceil(1000./P)*P;
  28. }
  29. cout << price;
  30. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty