A. Pasha and Stick
来源:互联网 发布:补水的水乳推荐知乎 编辑:程序博客网 时间:2024/05/22 10:32
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.
The first line of the input contains a positive integer n (1 ≤ n ≤ 2·109) — the length of Pasha's stick.
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.
6
1
20
4
There is only one way to divide the stick in the first sample {1, 1, 2, 2}.
Four ways to divide the stick in the second sample are {1, 1, 9, 9}, {2, 2, 8, 8}, {3, 3, 7, 7} and {4, 4, 6, 6}. Note that {5, 5, 5, 5} doesn't work.
解题说明:水题,按照题目要求构造即可。
#include<cstdio>#include <cstring>#include<cmath>#include<iostream>#include<algorithm>#include<vector>using namespace std;int main (){int n;scanf("%d",&n);if(n%2!=0){printf("0\n");}else{n/=2;printf("%d\n",(n-1)/2);}return 0;}
- A. Pasha and Stick
- 610A Pasha and Stick
- Codeforces 610A Pasha and Stick 【水题】
- codefroces#337 A Pasha and Stick【思维】
- codeforces 610A Pasha and Stick
- 【CodeForces】[610A]Pasha and Stick
- codefroces#337 A Pasha and Stick【思维】
- Pasha and Stick Codeforces 610A
- CodeForces 610A Pasha and Stick
- Codeforces 610A Pasha and Stick
- 【CodeForces 610A】Pasha and Stick
- 【codeforces 610A】Pasha and Stick
- Pasha and Stick
- Pasha and Stick
- Pasha and Stick
- Pasha and Stick
- 【codeforces】Pasha and Stick
- Pasha and Stick
- poj3660
- 微信朋友圈技术之道:三个人的后台团队与每日十亿的发布量
- Oracle误删除数据恢复
- 网络编程2
- Some OJ
- A. Pasha and Stick
- 排序
- 21. Merge Two Sorted Lists
- 1011. A+B和C (15)
- SQL循环语句
- MySQL和SQL Server比较
- pragma code_seg
- Swift入门———逻辑分支
- 2015’12杭电校赛1002 Polygon (计算几何)