[Codeforces] [610A] Pasha and Stick

Problem Description

Loading...

Problem Analysis

We can regard the number n as being composed of two distinct even numbers
The question is how many such combinations exist
It is known that when it is odd or $n==2$ there is no solution

For the numbers that combine into n, one must be smaller than n/2 and one larger than n/2
So we can use n/2 to count the number of kinds
And in the range 1~n/2 there are n/4 even numbers
When n/2 is even, the final result cannot be the number itself
When it is odd, the final result is (n/2-1)/2

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include<stdio.h>
int main() {
    __int64 n;
    while(scanf("%I64d",&n)!=EOF) {
        if(n<4||n%2==1)
            printf("0\n");
        else if(n/2%2==0)
            printf("%d\n",n/4-1);
        else
            printf("%d\n",(n/2-1)/2);
    }
    return 0;
}

Loading...