当前位置:网站首页>A. Beat The Odds
A. Beat The Odds
2022-06-29 21:35:00 【Felven】
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Given a sequence a1,a2,…,ana1,a2,…,an, find the minimum number of elements to remove from the sequence such that after the removal, the sum of every 22 consecutive elements is even.
Input
Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of test cases. Description of the test cases follows.
The first line of each test case contains a single integer nn (3≤n≤1053≤n≤105).
The second line of each test case contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109) — elements of the sequence.
It is guaranteed that the sum of nn over all test cases does not exceed 105105.
Output
For each test case, print a single integer — the minimum number of elements to remove from the sequence such that the sum of every 22 consecutive elements is even.
Example
input
Copy
2 5 2 4 3 6 8 6 3 5 9 7 1 3
output
Copy
1 0
Note
In the first test case, after removing 33, the sequence becomes [2,4,6,8][2,4,6,8]. The pairs of consecutive elements are {[2,4],[4,6],[6,8]}{[2,4],[4,6],[6,8]}. Each consecutive pair has an even sum now. Hence, we only need to remove 11 element to satisfy the condition asked.
In the second test case, each consecutive pair already has an even sum so we need not remove any element.
Problem solving instructions : Water problem , Or delete all the odd numbers 、 Or delete all even numbers .
#include"stdio.h"
#include"math.h"
int main()
{
int k, b, x;
scanf("%d", &k);
for (int i = 0; i<k; i++)
{
int br = 0;
scanf("%d", &b);
for (int j = 0; j<b; j++)
{
scanf("%d", &x);
if (x % 2 != 0)
{
br++;
}
}
if (br > b - br)
{
printf("%d\n", b - br);
}
else
{
printf("%d\n", br);
}
}
return 0;
}边栏推荐
- Matlab adds noise / disturbance to data
- [fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design
- Common methods of string class
- Which brokerage commission is the lowest and safest
- Topic39——78. 子集
- 亚马逊商品详情API接口-(item_get-获得AMAZON商品详情接口),亚马逊详情API接口
- [advanced ROS chapter] lesson 2 custom header and source file encapsulation
- CORDIC based Signal Processor desgn
- varnish 503 no backend connection – varnish健康检查
- 【云原生实战】KubeSphere实战——多租户系统实战
猜你喜欢

Analysis on the true topic of "cost management" by Guangdong second-class cost engineer

Detailed description of gaussdb (DWS) complex and diverse resource load management methods

Yolov6 training your own data record +yolov5 comparison test

直播预告 | PostgreSQL 内核解读系列第一讲:PostgreSQL 系统概述

About Effect Size

什么是 SYN 洪水攻击?如何防护?

《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示

时钟树综合(CTS)

LSF-bsub命令

Design of VHDL telephone billing system
随机推荐
What is a SYN Flood attack? How to protect?
双目立体视觉摄像头的标定、矫正、世界坐标计算(opencv)
PostgreSQL weekly news - June 22
[advanced ROS] Lecture 3 ROS file system and distributed communication
Topic39——78. 子集
Digital password lock Verilog design + simulation + on board verification
Rsync 建立多目录模块的方法
如何从外表判断导电滑环的质量
唯品会关键词搜索API接口(item_search-按关键字搜索唯品会商品API接口),唯品会API接口
Recommended books -- walking in the daytime and at night
Win10添加ssh公钥
每周招聘|DBA数据工程师,年薪35+ ,梦起九州,星河灿烂!
Navigation [microcomputer principle]
Vipshop product details API interface (item_get- get vipshop product details interface), vipshop details API interface
Vipshop Keyword Search API interface (item_search- search vipshop commodity API interface by keyword), vipshop API interface
shell 实现Memcache缓存命中率监控脚本
[fishing artifact] code tool for lowering the seconds of UI Library -- form part (I) design
高校如何基于云原生构建面向未来的智慧校园?全栈云原生VS传统技术架构
My creation anniversary