https://www.acmicpc.net/problem/10158
#include<stdio.h>
int main() {
int w,h,p,q,t;
scanf("%d %d %d %d %d",&w,&h,&p,&q,&t);
int x=t%(2*w);
int y=t%(2*h);
if(x<=w-p) p+=x;
else if(x<=2*w-p) p=w-(x-w+p);
else p=x-2*w+p;
if(y<=h-q) q+=y;
else if(y<=2*h-q) q=h-(y-h+q);
else q=y-2*h+q;
printf("%d %d",p,q);
}