当前位置:网站首页>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;
}
边栏推荐
- JS array = number assignment changes by one, causing the problem of changing the original array
- Learning notes: detailed use of 12864 LCD module
- When the graduation season comes, are you ready? What are we going to do
- 【transformer】DeiT
- Use of golang exec.command
- 长安链双花交易防范策略
- Installation and configuration of automatic operation and maintenance management workers ansible
- JVM tuning summary -xms -xmx -xmn -xss
- C control open source library: download of metroframework
- Ida Pro novice tutorial
猜你喜欢

【愚公系列】2022年7月 Go教学课程 015-运算符之赋值运算符和关系运算符

Insight into mobile application operation growth in 2022 white paper: the way to "break the situation" in the era of diminishing traffic dividends

Upload and download multiple files using web APIs

微生物健康,不要排斥人体内微生物

JZ7 rebuild binary tree

In container multicast
![[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators](/img/37/4a892b96bec8cfa7efe38046c5dfc9.png)
[Yugong series] July 2022 go teaching course 015 assignment operators and relational operators of operators
![[datawhale202207] reinforcement learning: the foundation of reinforcement learning](/img/1e/6ba657da14508854207aac51992ad8.png)
[datawhale202207] reinforcement learning: the foundation of reinforcement learning

Robot engineering - teaching quality - how to judge

LeetCode46全排列(回溯入门)
随机推荐
Common mode inductance has been heard many times, but what principle do you really understand?
Standard C language 89
Android interview question: why do activities rebuild ViewModel and still exist—— Jetpack series (3)
__ str__ Output class
Quick sort code implementation
Jstat command summary [easy to understand]
mvc与三层结构终极区别
Bug notes
Argocd user management, RBAC control, script login, APP synchronization
【每日一题】剑指 Offer II 115. 重建序列
Prevention strategy of Chang'an chain Shuanghua transaction
Microorganisms are healthy. Don't exclude microorganisms in the human body
探讨影响自动化测试成败的重要因素
Easy to use code statistics tool
Download and run the C open source control metroframework demo project
EFCore高级Saas系统下单DbContext如何支持不同数据库的迁移
[add, delete, modify, and check the array base]
共模电感听过很多次,但是什么原理你们真的懂吗?
MySQL queries the table name under the current database
How to convert multi row data into multi column data in MySQL