Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- long long n,m,k,k1,cnt,t;
- bool odd;
- int main()
- {
- cin>>n>>m>>k;
- k1=(n*m)/k;
- if((n*m)%k)
- {
- odd=1;
- }
- cout<<k1<<' ';
- for(int i=0; i<n; i++)
- {
- if(!i%2)
- {
- for(int j=0; j<=m-1; j++)
- {
- cout<<i+1<<' '<<j+1<<' ';
- cnt++;
- if(cnt==k1)
- {
- t++;
- cnt=0;
- if(odd)
- {
- if(t==k-1)
- {
- k1++;
- }
- }
- if(t<k)
- {
- cout<<endl;
- cout<<k1<<' ';
- }
- }
- }
- }
- else
- {
- for(int j=m-1; j>=0; j--)
- {
- cout<<i+1<<' '<<j+1<<' ';
- cnt++;
- if(cnt==k1)
- {
- t++;
- cnt=0;
- if(odd)
- {
- if(t==k-1)
- {
- k1++;
- }
- }
- if(t<k)
- {
- cout<<endl;
- cout<<k1<<' ';
- }
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement