Advertisement
artemgf

Рельсы

Feb 18th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. /*#include <iostream>
  2. #include <string>
  3. #include <map>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int age, i, n;
  9.     string s;
  10.     map<int, int> a;
  11.     cin >> n;
  12.     for (i = 0; i < n; i++)
  13.     {
  14.         cin >> age;
  15.         a[age]++;
  16.     }
  17.     map<string, int>::iterator iter;
  18.     for (iter = a.begin(); iter != a.end(); iter++)
  19.         cout << iter->first << " " << iter->second << endl;
  20.     system("pause");
  21.     return 0;
  22. }*/
  23. #define _USE_MATH_DEFINES
  24. #include <iostream>
  25. #include <string>
  26. #include <map>
  27. #include <set>
  28. #include <algorithm>
  29. #include <vector>
  30. #include <stdio.h>
  31. #include <cmath>
  32. #include <math.h>
  33. #include <queue>
  34. #include <stack>
  35. #include <climits>
  36. #include <deque>
  37. #include <ctime>
  38.  
  39. using namespace std;
  40.  
  41. typedef long long ll;
  42. typedef unsigned long long ull;
  43. typedef unsigned int ui;
  44.  
  45. #define mh() make_heap()
  46. #define poph() pop_heap()
  47. #define pushh() push_heap()
  48. #define sor(n) n.begin(), n.end()
  49. #define rsor(n) n.rbegin(), n.rend()
  50. #define mp make_pair
  51. #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
  52. #define p(T) pair<T,T>
  53. #define znac(l) abs(l)/l
  54. const ll ok = ll(1e9 + 7);
  55.  
  56. int main()
  57. {
  58. #ifndef ONLINE_JUDGE
  59.     files;
  60. #endif
  61.     ll n;
  62.     cin >> n;
  63.     double S, l;
  64.     cin >> S >> l;
  65.     ll k = S / l;
  66.     ll answ = k*n;
  67.     double os = S - k*l;
  68.     if (os > 1e-9)
  69.     {
  70.         double p = l / os;
  71.         k = ll(p+1e-9);
  72.         if (k >= n)
  73.             answ += 1;
  74.         else
  75.             answ += n/k+bool(n%k);
  76.     }
  77.     cout << answ;
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement