Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long n, m, k, x, y;
- int main() {
- cin >> n >> m >> k >> x >> y;
- long long cnt = 0;
- long long q = n*m;
- long long p = 0;
- long long s = 0;
- long long e = 0;
- while(true){
- e++;
- if(cnt + q > k){
- if(p == 0){
- for(long long i = 1; i <= n; i++){
- for(long long j = 1; j <= m; j++){
- if(x == i && y == j){
- s++;
- }
- if(cnt == k){
- if(n == m){
- cout << e << e << e;
- }
- else{
- cout << e << e-1 << s;
- }
- }
- cnt++;
- }
- }
- }
- else if(p == 1){
- for(long long i = n-1; i >= 1; i--){
- for(long long j = 1; j <= m; j++){
- if(x == i && y == j){
- s++;
- }
- if(cnt == k){
- if(n == m){
- cout << e << e << e;
- }
- else{
- cout << e << e-1 << s;
- }
- }
- cnt++;
- }
- }
- }
- }
- else{
- cnt+=q;
- }
- p++;
- if(cnt == k){
- if(n == m){
- cout << e << e << e;
- }
- else{
- cout << e << e-1 << s;
- }
- return 0;
- }
- }
- if(n == m){
- cout << e << e << e;
- }
- else{
- cout << e << e-1 << s;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement