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;
}
Codeforces Round #337 (Div. 2) A. Pasha and Stick 数学的更多相关文章
- Codeforces Round #337 (Div. 2) A. Pasha and Stick 水题
A. Pasha and Stick Pasha has a wooden stick of some positive integer length n. He wants to perform ...
- Codeforces Round #297 (Div. 2)B. Pasha and String 前缀和
Codeforces Round #297 (Div. 2)B. Pasha and String Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...
- Codeforces Round #622 (Div. 2) B. Different Rules(数学)
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n ...
- Codeforces Round #337 (Div. 2)
水 A - Pasha and Stick #include <bits/stdc++.h> using namespace std; typedef long long ll; cons ...
- Codeforces Round #337 (Div. 2) A水
A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #311 (Div. 2)B. Pasha and Tea 水题
B. Pasha and Tea Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/prob ...
随机推荐
- Mountain Road
题意: n个车,过一条路,有不同的方向,路上不允许同时有两个方向的车,给出每个车的起始时间,方向,和经过路花费的时间,车最小间隔10个时间,求最后一个车通过路的最早的时间. 分析: dp[i][j][ ...
- MicroSD卡(TF卡)SPI模式实现方法
现在我们手机的内存卡多为Micro SD卡,又叫TF卡,所以Micro SD卡比SD卡常见.自己曾经也想写写SD卡的读取程序,但又不想特地再去买个SD卡,这时想起手机内存卡不是和SD卡很像吗?在网上查 ...
- ASP.NET MVC3细嚼慢咽---(1)网站创建与发布
这一节我们演示下怎样使用VS2010创建与发布MVC3建立的网站.使用VS2010创建MVC3.0网站,需要下载MVC3.0的安装包,这个大家可以去网络上下载. 1.项目创建 ...
- 捣蛋phpwind过滤器执行流程
从上一篇我们就大概就知道过滤器的定义和怎样去配置,这一节来说说执行流程 public function run($handlerAdapter = null) { $handlerAdapter != ...
- hadoop2.2伪分布安装加2.2源码编译
配置linux基本环境: --> java.ip.hostname.hosts.iptables.chkconfig.ssh环境配置 hadoop2.2安装在linux64位机器上,需要对源码进 ...
- jquery对象和js对象,以及它们的互相转换
jq对象无法使用DOM对象的方法,互相都不能用 ***jq对象转换成DOM对象的2中方法 1.$('div')[0下标]:jq对象是类似数组对象有长度,所以可以通过下标查找到它的DOM对象 2.$(' ...
- [转]比较 Rational Unified Process (RUP) 和 Microsoft Solutions Framework (MSF)
文档选项 将此页作为电子邮件发送 级别: 初级 Sandra Sergi Santos, 软件工程专家, IBM 2007 年 6 月 15 日 本文来自于 Rational Edge:Micro ...
- 【Visual Studio2010】创建XAML分析插件
最近项目[Silverlight]中的需要实现国际化,需要对所有控件进行一个处理.由于使用了Telerik的控件,只需要去掉原有的Label或者Header属性,然后添加一个资源Key即可.但是在项目 ...
- Dagger2学习资源
文章 Jack Wharton关于Dagger的幻灯片 代码 用Dagger2改写Jack Wharton的U+2020 我自己写的,包含了dagger2和单元测试 chiuki写的,包含了dagge ...
- ArcObjects10.0引用控件报错
错误如下:ArcGIS version not specified. You must call RuntimeManager.Bind before creating any ArcGIS comp ...