当前位置:网站首页>CodeForces 1417B Two Arrays
CodeForces 1417B Two Arrays
2022-07-25 06:46:00 【Zero if】
Topic linking
The question :
Give you a group number and an unfortunate number T, It is required to divide the array into two parts , Marked as 1or0, A fellow 1 perhaps 0 The sum of the two numbers of is not equal to T, Find any kind of division .
Their thinking :
T/2+T/2=T, In this case , Put all less than T/2 Put aside the number of , Greater than T/2 Put the number of on the other side , In this way, no matter how you add it, it will not be added T. Exactly equal to T/2 The data of is 0 One for 1 In this way, it is opened alternately .
#include<bits/stdc++.h>
#define maxn 1000001
using namespace std;
long long int a[maxn];//int Meeting TE
int main()
{
int num;
cin>>num;
while(num--)
{
long long int n,T;
cin>>n>>T;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int x=1;
for(int i=1;i<=n;i++)
{
if(T%2!=0)
{
int t=T/2;
if(a[i]>t)
{
a[i]=1;
}
else
{
a[i]=0;
}
}
else
{
int t=T/2;
if(a[i]>t)
{
a[i]=1;
}
else if(a[i]<t)
{
a[i]=0;
}
else
{
a[i]=x;
x=1-x;
}
}
}
for(int i=1;i<=n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}
边栏推荐
- [yolov5 practice 3] traffic sign recognition system based on yolov5 - model training
- Can communication test based on STM32: turn the globe
- In container multicast
- RecycleView实现item重叠水平滑动
- Scientific computing library numpy Foundation & Improvement (Understanding + explanation of important functions)
- 如何学习 C 语言?
- Two week learning results of machine learning
- Baidu Post Bar crawler gets web pages
- C control open source library: download of metroframework
- How can dbcontext support the migration of different databases in efcore advanced SaaS system
猜你喜欢

JZ7 rebuild binary tree

10分钟看懂Jmeter 是如何玩转 redis 数据库的

How to learn C language?

【C】程序环境和预处理

Labelme labels different objects, displays different colors and batch conversion

健康打卡每日提醒累了?那就让自动化帮你---HiFlow,应用连接自动化助手

Developers must read: 2022 mobile application operation growth insight white paper

Upload and download multiple files using web APIs

What are the hazards of insufficient sleep?

Recycleview realizes horizontal sliding of overlapping items
随机推荐
C # --metroframework framework calls the metromodernui library and uses it in the toolbar
常吃发酵馒头是否会伤害身体
Software engineering in Code: regular expression ten step clearance
R strange grammar summary
Temperature table lookup and calculation formula
The code of Keil and Si compiler is not aligned??
Mysql database
Qt实战案例(53)——利用QDrag实现拖拽拼图功能
In container multicast
【愚公系列】2022年7月 Go教学课程 015-运算符之赋值运算符和关系运算符
Install, configure, and use the metroframework in the C WinForms application
Oracle table creation statement template
Restrict Su command and sudo mechanism to promote nmap and console command netstat
【Jailhouse 文章】Base Architectures for virtual-physical computing(2018)
mvc与三层结构终极区别
【C】程序环境和预处理
Mlx90640 infrared thermal imager temperature measurement module development notes (I)
Example demonstration of math.random() random function
Developers must read: 2022 mobile application operation growth insight white paper
容器内组播