• Codeforces Round #337 (Div. 2) A. Pasha and Stick 数学


    A. Pasha and Stick

    题目连接:

    http://www.codeforces.com/contest/610/problem/A

    Description

    Pasha has a wooden stick of some positive integer length n. He wants to perform exactly three cuts to get four parts of the stick. Each part must have some positive integer length and the sum of these lengths will obviously be n.

    Pasha likes rectangles but hates squares, so he wonders, how many ways are there to split a stick into four parts so that it's possible to form a rectangle using these parts, but is impossible to form a square.

    Your task is to help Pasha and count the number of such ways. Two ways to cut the stick are considered distinct if there exists some integer x, such that the number of parts of length x in the first way differ from the number of parts of length x in the second way.

    Input

    The first line of the input contains a positive integer n (1 ≤ n ≤ 2·109) — the length of Pasha's stick.

    Output

    The output should contain a single integer — the number of ways to split Pasha's stick into four parts of positive integer length so that it's possible to make a rectangle by connecting the ends of these parts, but is impossible to form a square.

    Sample Input

    20

    Sample Output

    4

    Hint

    题意

    给你一个长度为n的木棍,问你有多少种切法,切出四条边,然后使得切出来的能够组成矩形,而不能组成正方形

    题解:

    组成矩形很简单,l + h = n/2 ,种类数就是 n/4

    由于l = h的话是正方形,就-1就好了

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        long long ans;
        cin>>ans;
        if(ans%2==1)
            return puts("0");
        cout<<(ans/2-1)/2<<endl;
    }
  • 相关阅读:
    本机mysql 5.7服务启动后停止,某些服务在未有其他应用程序使用时停止
    java数据结构 • 面向对象 • 异常 • 随机数·时间
    获取对象信息
    集合的运算律
    常用的逻辑符号
    未解决问题
    继承和多态
    访问权限
    类和实例
    第三方模块安装
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5081864.html
Copyright © 2020-2023  润新知