Five school freshmen friendlies (part solution to a problem)

F title
original title: Portal
question are intended: The title, from the top right corner of a board (1, m), each may be left, lower, lower-left movement, who can not move loses.
Ideas:
the first can range from small start, losing the upper hand when 1x1 point, a line or an odd number of points when losing the upper hand.
As FIG 3x3:
L: sente losing W: upper hand win

L W L
W W W
L W L

Law can be seen that when m is an odd number n and the upper hand will be lost. (Can draw bigger also find the law)
to prove the case (this figure extension) is the person at the time of the operation need to come to the point of losing the upper hand to win.

#include<cstdio>
int main()
{
	int n,m;
	while(scanf("%d %d",&n,&m)&&(n||m))
	{
		if(n%2!=0&&m%2!=0)
			printf("What a pity!\n");
		else
			printf("Wonderful!\n");
	}
	return 0;
}

I question
the original question: Portal
meaning of the questions: put a positive integer is a prime number decomposition a composite number.
Idea:
n-3 is an odd-number of 3-n-
n-2 is the even-number n-2 to
note that n <= 5 Not

#include<cstdio>
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int n;
        scanf("%d",&n);
        if(n<=5){
            printf("-1\n");
            continue;
        }
        if(n&1){
            printf("%d %d\n",3,n-3);
        }
        else
            printf("%d %d\n",2,n-2);
    }
    return 0;
}

Released two original articles · won praise 0 · Views 228

Guess you like

Origin blog.csdn.net/weixin_45444789/article/details/104124493