Ehab Is an Odd Person
https://codeforces.com/contest/1174/problem/B
题解:排序+思维
如果同时存在奇数偶数就排序
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt1,cnt2,flag,temp,sum;
int a[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]),(a[i]&1?cnt1++:cnt2++);if(cnt2&&cnt1)sort(a+1,a+n+1);for(int i=1;i<=n;i++)printf("%d%c",a[i]," \n"[i==n]);//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Ehab Is an Odd Person相关推荐
- Codeforces Round #563 (Div. 2)/CF1174
Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...
- Codeforces 862B - Mahmoud and Ehab and the bipartiteness
862B - Mahmoud and Ehab and the bipartiteness 思路:先染色,然后找一种颜色dfs遍历每一个点求答案. 代码: #include<bits/stdc+ ...
- Codeforces Round #649 (Div. 2)C. Ehab and Prefix MEXs[排列的构造]
C. Ehab and Prefix MEXs 题目大意: 解题思路:题目说保证a数组是非递减的,那么如果某位置a[i]!=a[i−1]a[i]!=a[i-1]a[i]!=a[i−1]那么这个位置ii ...
- P2955 [USACO09OCT]奇数偶数Even? Odd?
题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive int ...
- 【Codeforces1327A】: Sum of Odd Intergers C/C++题解
Sum of Odd Intergers 题解 Codeforces[1327A]: Sum of Odd Intergers题解 一.题目描述 二.解题思路 三.注意事项 四.完整代码 五.另一种不 ...
- C++Odd Even Sort奇偶排序的实现算法(附完整源码)
C++Odd Even Sort奇偶排序的实现算法 C++Odd Even Sort奇偶排序的实现算法完整源码(定义,实现,main函数测试) C++Odd Even Sort奇偶排序的实现算法完整源 ...
- CodeForces - 1549F1 Gregor and the Odd Cows (Easy)(几何+数论)
题目链接:点击查看 题目大意:给出二维平面上的 nnn 个点,任意选择出三个点可以构成一个三角形,现在问满足下面条件的三角形的个数: 三角形面积为整数 三角形包含的(不包括边界)整数点为奇数 其中所有 ...
- Why is it recommended to create clusters with odd number of nodes? | 为什么集群节点建议奇数个?
Why is it recommended to create clusters with odd number of nodes? | 为什么集群节点建议奇数个? 常说集群节点要奇数台,因为当你节点 ...
- Leet Code OJ 328. Odd Even Linked List [Difficulty: Easy]
题目: Given a singly linked list, group all odd nodes together followed by the even nodes. Please note ...
最新文章
- 模板文件默认标准版首页模板.html未找到!,html页模板
- Memcached深度分析【转载】
- postgresql10.5安装
- 动态字段插入及查询redis小结
- raid卡的结构示意图
- sublime text3配置Python2、Python3的编译环境
- webpack 引入css link,demo11 webpack处理css
- 大数据认知计算在内容安全管控中的应用
- 山寨一个ini文件的解析器
- @property 各个属性作用【使用时最需注意strong/weak类型】【补充部分内存知识】...
- 【报告分享】致胜直播带货十大法则.pdf(附下载链接)
- 【工具使用系列】关于 MATLAB 神经网络故障诊断,你需要知道的事
- Ubuntu16.04安装中文字体SimHei
- OFDM系统中的信号检测算法分类和详解
- 积小胜为大胜 投资大师教你三种有效的投资方法
- Android端简单数据库实现
- matlab计算一组数的函数值_2.Matlab数值数组及其运算
- 数据结构-中序遍历二叉树(基于C++)
- Thinkpad 笔记本散热风扇声音大解决办法
- Flash动画个人学习总结
热门文章
- sketch 将动图转换为json_开源 | Picasso:sketch设计稿智能解析工具
- ubuntu安装python库_Ubuntu18.04一次性升级Python所有库的方法步骤
- linux 播放器系统,在Linux上安装和使用开源视频播放器MPlayer
- python序列类型唯一的映射类型_python2.x学习笔记(8)-映射和集合类型
- MyEclipse部署Web项目Servers报错:NullPointerException at com.genuitec.eclipse.ast.deploy.core.Deployment
- oracle查询记录插入,我应该使用哪种查询语法在Oracle数据库中插入记录?
- 【小白学习tensorflow教程】四、使用 tfhub中的模型EfficientDet-Lite2 进行对象检测
- 二、 elasticsearch安装和概念
- html弹窗页面控制大小,使用JS弹出新窗口,并设置窗口的大小和位置等相关属性,传递参数...
- 零样本性能超越GPT-3!谷歌提出1370亿参数自回归语言模型