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;
    }
  • 相关阅读:
    Lucene底层原理和优化经验分享(1)-Lucene简介和索引原理
    mysql 索引
    C++ 后台进程 daemon
    Linux进程状态
    实现一个简单的shared_ptr
    [LeetCode] Factorial Trailing Zeroes
    完美转发
    排序
    每天五个java相关面试题(7)--线程篇
    程序员为什么会淡忘?
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5081864.html
Copyright © 2011-2022 走看看