#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int w,h;
    scanf("%d %d",&w,&h);
    int p,q;
    scanf("%d %d",&p,&q);
    int t;
    scanf("%d",&t);

    int tx=p+t;
    int ty=q+t;
    tx%=(2*w);
    ty%=(2*h);

    int fx=0;
    if(tx <= w)
        fx=tx;
    else
        fx=2*w-tx;

    int fy=0;
    if(ty <= h)
        fy=ty;
    else
        fy=2*h-ty;

    printf("%d %d",fx,fy);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: