Advertisement
askarulytarlan

несправедливый опрос

Feb 4th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long n, m, k, x, y;
  6.  
  7. int main() {
  8. cin >> n >> m >> k >> x >> y;
  9. long long cnt = 0;
  10. long long q = n*m;
  11. long long p = 0;
  12. long long s = 0;
  13. long long e = 0;
  14. while(true){
  15. e++;
  16. if(cnt + q > k){
  17. if(p == 0){
  18. for(long long i = 1; i <= n; i++){
  19. for(long long j = 1; j <= m; j++){
  20. if(x == i && y == j){
  21. s++;
  22. }
  23. if(cnt == k){
  24. if(n == m){
  25. cout << e << e << e;
  26. }
  27. else{
  28. cout << e << e-1 << s;
  29. }
  30. }
  31. cnt++;
  32. }
  33. }
  34. }
  35. else if(p == 1){
  36. for(long long i = n-1; i >= 1; i--){
  37. for(long long j = 1; j <= m; j++){
  38. if(x == i && y == j){
  39. s++;
  40. }
  41. if(cnt == k){
  42. if(n == m){
  43. cout << e << e << e;
  44. }
  45. else{
  46. cout << e << e-1 << s;
  47. }
  48. }
  49. cnt++;
  50. }
  51. }
  52. }
  53. }
  54. else{
  55. cnt+=q;
  56. }
  57. p++;
  58. if(cnt == k){
  59. if(n == m){
  60. cout << e << e << e;
  61. }
  62. else{
  63. cout << e << e-1 << s;
  64. }
  65. return 0;
  66. }
  67. }
  68. if(n == m){
  69. cout << e << e << e;
  70. }
  71. else{
  72. cout << e << e-1 << s;
  73. }
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement