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;
}
最新文章
- js 压缩工具总结
- 读Java 804 - Quick refresher
- 浅谈 MVP in Android
- 连接器|网络滤波连接器|电脑连接器|RJ45变压器-华联威电子有限公司
- oralce health monitor
- CentOS6.4卸载自带的OpenJDK并安装jdk1.6.21
- 写Java程序的三十个基本规则【新手必读】
- ES1:Windows下安装ElasticSearch
- ceph 高级运维
- BZOJ5412 : circle
- LDAP与实现
- myls
- 【XSY1515】【GDKOI2016】小学生数学题 组合数学
- QToolButton按钮
- 【LeetCode】547. 朋友圈
- time since epoch
- javascript将算法复杂度从O(n^2)做到O(n)
- VS2005快捷键大全
- VS中 Winform查看窗体内控件之间的相互关系
- uva 12086 线段树or树状数组练习