【codeforces】-610A-Pasha and Stick(水)
来源:互联网 发布:数据恢复qq 编辑:程序博客网 时间:2024/05/01 12:06
点击打开题目链接
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.
看看能不能构成长方形即可,奇数不可以,特判。是长方形加1,不是是正方形不加。
#include<cstdio>int main(){__int64 n,num;while(~scanf("%I64d",&n)){if(n&1)printf("0\n");else{num=0;n=n>>1;for(int i=1;i<=(n>>1);i++){if(i!=(n-i))num++;}printf("%I64d\n",num);}}return 0;}
- CodeForces 610 A. Pasha and Stick(水~)
- CodeForces 610A Pasha and Stick (水)
- 【CodeForces】610A - Pasha and Stick(水)
- 【codeforces】-610A-Pasha and Stick(水)
- Codeforces 610A Pasha and Stick 【水题】
- codeforces 610A Pasha and Stick
- 【CodeForces】[610A]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
- 610A Pasha and Stick
- 【codeforces】Pasha and Stick
- 【codeforces】Pasha and Stick
- A. Pasha and Stick
- Codeforces Round #337 (Div. 2) A. Pasha and Stick (水)
- codefroces#337 A Pasha and Stick【思维】
- Bulbs
- POJ 3009 Curling 2.0
- Ibaitis Caused by: com.ibatis.common.beans.ProbeException: Error getting ordinal list from JavaBean.
- hdu 题目分类
- 单词读音
- 【codeforces】-610A-Pasha and Stick(水)
- 25个最受用户喜爱的免费WordPress插件:第1个~第5个
- 8086汇编语言 使用link连接,生成exe文件
- 二分查找——Search Insert Position
- notepad++ 左面显示文件夹结构
- 文章标题POJ 2785:4 Values whose Sum is 0?(二分)
- 最小公倍数
- Listview 与 Button和Text的焦点冲突问题~
- apk前缀debug、release、unaligned的区别