4452 simulate a water question, 4452 simulate a water question

Source: Internet
Author: User

4452 simulate a water question, 4452 simulate a water question

#include<stdio.h>#include<string.h>#include<iostream>using namespace std;int abs(int a){    return a>0?a:(-a+1);}int main(){    int n,i,j,s1,t1,s2,t2,m;    char first[5],second[5];    while(~scanf("%d",&n),n)    {        scanf("%s",first);        scanf("%d%d",&s1,&t1);        scanf("%s%d%d",second,&s2,&t2);        scanf("%d",&m);        int fx=1,fy=1,sx=n,sy=n;        for(i=1;i<=m;i++)        {            if(first[0]=='W')            {                if(fy-1<s1)                {                    fy=s1-fy+2;                    first[0]='E';                }                else fy-=s1;            }             else if(first[0]=='E')            {                if(n-fy<s1)                {                    fy=2*n-s1-fy;                    first[0]='W';                }                else fy+=s1;            }            else if(first[0]=='N')            {                if(fx-1<s1)                {                    fx=s1-fx+2;                    first[0]='S';                }                else fx-=s1;            }                      else            {                if(n-fx<s1)                {                    fx=2*n-s1-fx;                    first[0]='N';                }                else fx+=s1;            }            if(second[0]=='W')            {                if(sy-1<s2)                {                    sy=s2-sy+2;                    second[0]='E';                }                else sy-=s2;            }             else if(second[0]=='E')            {                if(n-sy<s2)                {                    sy=2*n-s2-sy;                    second[0]='W';                }                else sy+=s2;            }            else if(second[0]=='N')            {                if(sx-1<s2)                {                    sx=s2-sx+2;                    second[0]='S';                }                else sx-=s2;            }                      else            {                if(n-sx<s2)                {                    sx=2*n-s2-sx;                    second[0]='N';                }                else sx+=s2;            }            if(fx==sx&&fy==sy)            {                char p=first[0];                first[0]=second[0];                second[0]=p;            }            else            {                if(i%t1==0)                {                    if(first[0]=='W') first[0]='S';                    else if(first[0]=='E') first[0]='N';                    else if(first[0]=='N') first[0]='W';                    else first[0]='E';                }                if(i%t2==0)                {                    if(second[0]=='W') second[0]='S';                    else if(second[0]=='E') second[0]='N';                    else if(second[0]=='N') second[0]='W';                    else second[0]='E';                }            }        }        printf("%d %d\n",fx,fy);        printf("%d %d\n",sx,sy);    }    return 0;}

Poj basic questions

1004, calculate the average number of 12
2027. check whether A> = B is satisfied.
3030
3062 these two are also legend of the super water, temporarily too lazy to see.
1656, this should have been out of water. It is estimated that the question was originally made using a line segment tree or a tree array. However, the data size in the question is too small, directly simulate it .. It becomes a super question.
Let's take A few of them first. In particular, the difficulty of the first few questions can be the same as that of A + B ..

Noip2010 raise the first question of the semi-finals (called the question of water by the scalpers)

Just use the simulation method, open an array, write and draw on paper, and find a simple rule.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.