codeforces 610A Pasha and Stick

团体程序设计天梯赛-练习集 L2-2. 链表去重 数组模拟链表 L2-2. 链表去重 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一个带整数键值的单链表L,本题要求你编写程序,删除那些键值的绝对值有重复的结点。即对任意键值K,只有键值或其绝对值等于K的第一个 阅读详情

A. Pasha and Stick
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
input
6
output
1
input
20
output
4
Note

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 <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);

	//必须要是偶数才能组成长方形
	if (n % 2 == 0) {
		/*
		根据hint很容易得出规律
		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.
		如果n能被4整除,则要去掉一个相等的一对,例如{5, 5},否则的话不用去
		因为例如{4, 6} {6, 4}每种情况算了两边,所以最后除以2
		*/
		int ans = (n / 2 - (n % 4 ? 0 : 1)) / 2;
		printf("%d\n", ans);
	}
	else {
		puts("0");
	}
	return 0;
}




什么是 AIDV(AI 定义汽车):从软件定义到智能决策的范式革命 AI定义汽车(AIDV),是指以人工智能(尤其是大模型、深度学习、强化学习)为核心引擎,以车载AI芯片为算力底座,以“数据闭环”为迭代支撑,重构汽车感知、决策、执行全链路,实现“感知智能化、决策自主化、体验个性化、迭代自动化”的新一代智能汽车发展范式。其核心是让汽车从“执行工具”升级为“具备自主学习与智能决策能力的移动智能终端”,核心价值是“车与人的深度协同”与“复杂场景的自主适配”。 阅读详情

相关推荐

基于价值的深度强化学习:DQN

本文主要是介绍DQN原理和算法伪代码和代码实现,算法实现包括pytorch版本和stable-baselines3版本

溯源的专栏 1082

CodeForces - 610A. Pasha and Stick

点击打开链接 A. Pasha and Stick time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Pasha has a wooden stick of some positive integer length n.

pomake的博客 428

ThunderScope开源示波器

4CH,1GSa/S 开源示波器。前端很简洁,BUF802+LMH6518,ADC是HMCAD1511,用Xilinx A7 FPGA进行控制,数据通过PCIE总线传输到上位机处理。目前这个项目已经被挂到了Xilinx官网,强。设计日志:https://hackaday.io/project/180090-thunderscope开源地址:https://github.com/EEVengers/ThunderScope。

leida_wt的博客 8185

【CodeForces】[610A]Pasha and Stick

可把数n当做由两个不同的偶数组合而成 问有多少种组合可知当为奇数或n==2时无解 对于组合n的数必定是一个小于n/2一个大于n/2 所以可把n/2来求种类 而在1~n/2的范围里有n/4个偶数 当n/2位偶数,则最后结果不能为自身 当其为奇数,则最后结果为(n/2-1)/2

BoilTask Talk Show 460

图像调整亮度饱和度 c语言,【C#/WPF】调节图像的HSL(色相、饱和度、明亮度)...

先说概念:HSL是一种描述颜色的方式(其他颜色描述方式还有大家熟悉的RGB值)。HSL三个字母分别表示图像的Hue色相、Saturation饱和度、Lightness明亮度。需求:制作一个面板,包含三个滑动条,拖动滑动条可以修改目标图片的HSL值。即模仿PS中类似的功能,如下图:方案一:遍历所有像素点,修改每个点的HSL值。前台界面:一个Image控件显示目标图片,一个Button按钮点击一下降低...

weixin_39935777的博客 1154

新建菜单Office被替换为腾讯文档 - 解决方案

右键新建菜单中的Office被替换为腾讯文档。原因是安装了腾讯文档软件,此软件安装时会自动将新建菜单中的Office替换为腾讯文档,下文介绍解决方案。

NSJim的博客 2926

【CodeForces 610A】Pasha and Stick

Pasha and StickDescription 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

楚江枫 564

YOLOv11在视频流中的时序建模改进-(加入ConvLSTM或Transformer捕捉帧间关联)

本文提出了一种结合ConvLSTM和Transformer的改进YOLOv11算法,用于增强视频目标检测的时序建模能力。针对视频检测中运动模糊、遮挡等挑战,研究分析了ConvLSTM的局部时空特征建模和Transformer的全局注意力机制之间的互补性。通过数学公式详细阐述了ConvLSTM的门控机制和Transformer的自注意力计算原理,并提出分层融合策略:底层使用ConvLSTM处理高分辨率特征捕捉局部运动,高层应用Transformer建立全局时空关联。改进方案在YOLOv11架构中插入时序增强模

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 678

CodeForces 610A Pasha and Stick

F - Pasha and Stick Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Pasha has a wooden stick of some positive integer length n.

Calm微笑 420

二、TCP/IP协议之网络层(IP地址的格式、分类、报文格式)

数据报每经过一个路由器,路由器都要重新计算一下首部检验和,若首部未发生变化,则此结果必为 0,于是就保留这个数据报。对于网络号相的设备,无论实际所处的物理位置如何,它们都是处在同一个网络中。在首部的固定部分的后面是一些可选字段,其长度是可变的。IPv4 软件在存储器中维持一个计数器,每产生一个数据报,计数器就加 1,并将此值赋给标识字段。表示数据报在网络中的寿命,英文缩写是 TTL(Time To Live),功能是“跳数限制”。地址的网络号码字段用来标识一个网络,网络号码字段的前几位用来区分。

锦慈的技术博客 184

Linux安装MinIO(图文解说详细版)

最近开个新坑,就是在linux环境中操作开发环境,带大家玩转Linux,会整理出一篇Linux的专栏,欢迎大家订阅!! 富贵同学linux环境为CentOS7.8 版本。 上期跟大家说了一下OpenJDK的安装,这次说一下minio的安装 第一步,进入/opt 目录,创建minio文件夹 cd /opt mkdir minio 第二步,wget下载安装包: wget https://dl.minio.io/server/minio/release/linux-amd64/minio 第三步,进入m

编码人生 5万+

Codeforces 610A Pasha and Stick

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 t

WOLF的博客 347

YoloV8优化:感受野注意力卷积运算(RFAConv),效果秒杀CBAM和CA等 | 即插即用系列

感受野注意力卷积运算(RFAConv),解决卷积块注意力模块(CBAM)和协调注意力模块(CA)只关注空间特征,不能完全解决卷积核参数共享的问题

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 4263

Codeforces 610A Pasha and Stick 【水题】

A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a wooden stick of some positive

世界很大 996

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

【CodeForces】610A - Pasha and Stick(水)

点击打开题目 A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a woode

wyg1997 499

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

CodeForces - 610A-G - Pasha and Stick-思维

题目链接: http://codeforces.com/problemset/problem/610/A题目大意: 给定一个长度L,将其分为4段,要求能组成一个矩形,不能组成正方形,有多少种方案分析: 首先奇数肯定不能切隔组成矩形,需要特判,偶数中,若同时为4的倍数,说明矩形的长与宽之和为偶数,可能出现长与宽相等,所以总情况数减少一种代码:#include <cstdio>int main(

SD_Stjean的博客 484

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

CodeForces 610A Pasha and Stick (水)

A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a wooden stick of some positive

Benjamin_Z的博客 469

CodeForces 610A Pasha and Stick (拆数字组成长方形)

A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a wooden stick of some positive

Shyazhut 413

【codeforces】-610A-Pasha and Stick(水)

点击打开题目链接 A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a wooden st

Bear1998的博客 389

CodeForces 610 A. Pasha and Stick(水~)

Description 问构造一个长度为n的长方形(不包括正方形)有多少种方案 Input 一个整数n(1<=n<=2*10^9) Output 输出构造一个长度为n的长方形(不包括正方形)的方案数,长方形边长需为正整数 Sample Input 6 Sample Output 1 Solution 水题,n为奇ans=0,n为偶ans=(n/2-1)/2 Code#incl

ZSQ 693

CodeForces 610APasha and Stick(数学)

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

菜鸟的自我修养 392

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 part...

weixin_30352191的博客 119

Codeforces Round #337 (Div. 2) A Pasha and Stick B Vika and Squares

http://codeforces.com/contest/610/problem/A A题 很简单,就是给出n 然后n分成四段,能组成长方形而不能组成正方形的情况数 #include #include using namespace std; int main() { int n; while(cin >> n) { int ans ;

Pilgrim 623

hdu计算机学院大学生程序设计竞赛 2015’11 1002 投币洗衣机

投币洗衣机 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5966    Accepted Submission(s): 1495 Problem Description   如今大学生的生活条件越来越好了,近期

EventQueue的博客 1439
上一篇: hdu2795 Billboard 线段树单点更新区间最值
下一篇: hdu5652 India and China Origins 深搜+二分
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值