当前位置:网站首页>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;
}边栏推荐
- 如何在 SAP BTP ABAP 编程环境里直接调用 ABAP On-Premises 系统的 RFC 函数
- LSF-bsub命令
- Selection of materials for space conductive disc slip ring
- 广东二级造价工程师《造价管理》真题解析
- How to integrate MES system with ERP? This article tells you the answer
- flutter BottomNavigationBar切换页面保持状态
- Detailed explanation of key points in implementing MES system in Enterprises
- verilog实现DDS波形发生器模块,可实现频率、相位可调,三种波形
- 双目立体视觉摄像头的标定、矫正、世界坐标计算(opencv)
- Verilog implements DDS waveform generator module, which can realize adjustable frequency and phase, three waveforms
猜你喜欢

STM32 minimum system construction (schematic diagram)

【ROS进阶篇】第二讲 自定义头、源文件封装

空间导电盘式滑环材料的选择

Storage principle of string

Report delivery engineer

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

Application of VoIP push in overseas audio and video services

Matlab adds noise / disturbance to data

ads131a04 ADC verilog实现及仿真

A new Polaris has risen!
随机推荐
LeetCode 1. 两数之和
What is a SYN Flood attack? How to protect?
Threejs basic introduction
[cloud native practice] kubesphere practice - Multi tenant system practice
Common methods of string class
什么是 SYN 洪水攻击?如何防护?
Analysis of the factors affecting the transmission signal of the conductive slip ring
Application of VoIP push in overseas audio and video services
Amazon Keyword Search API interface (item_search- Amazon product search interface by keyword), Amazon API interface
THREEJS基础入门
Storage principle of string
Recruit | DBA Data Engineer every week with an annual salary of 35+. Dream of Kyushu and bright stars!
How to call RFC function of ABAP on premises system directly in SAP BTP ABAP programming environment
时钟树综合(CTS)
Redis (I) -- getting started with redis (1) -- redis introduction, installation and startup, and common configurations
leetcode:724. 寻找数组的中心下标
管理人员应具备的基本素质
Final review [microcomputer principle]
Clock tree synthesis (CTS)