Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long int ll;
  6. typedef pair<ll, ll> pii;
  7.  
  8.  
  9. #define se second
  10. #define fi first
  11. #define pb push_back
  12. #define mp make_pair
  13.  
  14. int main() {
  15. ios::sync_with_stdio(false);
  16. ll n,m,k,x,y;
  17. cin>>n>>m>>k>>x>>y;
  18. if(n==1 || n == 2) {
  19. ll maxi = 0,tot = n*m;
  20. maxi += (k/tot);
  21. ll rmd = k%tot;
  22. if(rmd > 0) {
  23. maxi ++;
  24. }
  25. ll mini = k/tot;
  26. ll base = k/tot;
  27. if(rmd >= (x-1)*m+y) {
  28. base++;
  29. }
  30. cout<<maxi<<" "<<mini<<" "<<base<<endl;
  31. return 0;
  32. }
  33. ll maxi = 0;
  34. ll tot = 2*(n-1)*m;
  35. ll rounds = k/tot;
  36. maxi += 2*rounds;
  37. ll rmd = k%tot;
  38. if(rmd>m) {
  39. maxi++;
  40. }
  41. if(rmd > n*m) {
  42. maxi++;
  43. }
  44. ll mini =rounds;
  45. //mini += tot;
  46. if(rmd >= n*m) {
  47. mini++;
  48. }
  49. ll base = rounds;
  50. if(x!=1 && x!=n) {
  51. base +=rounds;
  52. }
  53. if(x==1) {
  54. if(y <= rmd) {
  55. base++;
  56. }
  57. }
  58. else if(x==n) {
  59. if(y <= rmd-(n-1)*m) {
  60. base++;
  61. }
  62. } else {
  63. if(rmd > n*m) {
  64. base++;
  65. x = n-x;
  66. rmd -= (n-1)*m;
  67. } else {
  68. x--;
  69. }
  70. if(x*m + y <=rmd) {
  71. base++;
  72. }
  73. }
  74. cout<<maxi<<" "<<mini<<" "<<base<<endl;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement