zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    python split的用法
    大学排名爬虫
    一直在报错:ModuleNotFoundError: No module named 'bs4'.
    微信小程序部署到线上环境
    mybatis关联三张表查询对应字段名
    WPF图像裁剪控件
    git创建标签并推送到远程
    Windows7、10的热键屏蔽
    WPF使用SVG简单整理
    Visual Studio 注册码和下载
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5081864.html
Copyright © 2011-2022 走看看