CF1613B Absent Remainder
哇靠,做了一晚上题,刚开始各种模拟,一直超时,换了快读多过了一个样例,无了无了!刚进组的acmer代码太小白莫怪莫怪。先说一下思路吧,题目大意就是从数组里面找一对数,假设为x,y,如果x%y的结果在刚输入的数组中不存在,就输出,否则,就不输出,一共输出数组长度的一半多个;
技巧:找出数组中最小的数,令y为最小的数,无论x是多少,x%y的值都不在数列中。废话不多说,上代码
// Problem: CF1613B Absent Remainder
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF1613B
// Memory Limit: 250 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include <bits/stdc++.h>
#define ios \ios::sync_with_stdio(false); \cin.tie(0); \cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 2e5 + 10;
inline int read() //快读
{int x = 0, f = 1;char ch = getchar();while (ch < '0' || ch > '9') {if (ch == '-')f = -1;ch = getchar();}while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}return x * f;
}
ll a[maxn];
bool cmp(ll x, ll y)
{return x < y;
}
int main()
{int t;cin >> t;while (t--) {int n;cin >> n;int minn = 2e5 + 10;for (int h = 1; h <= n; h++) {a[h] = read();minn = a[h] > minn ? minn : a[h];}sort(a + 1, a + n + 1, cmp);//从大到小排序,不排序也可以,需特判int i, k, flag, ans = 0; //最小值等于数组自己的情况for (i = n; i >= 2 && ans != n / 2; i--) {//for循环可以有cout << a[i] << " " << minn << endl; //多个判断条件ans++; //记录输出了几组数据}}return 0;
}
CF1613B Absent Remainder相关推荐
- B. Absent Remainder
题目 B. Absent Remainder time limit per test2 seconds memory limit per test256 megabytes inputstandard ...
- 【CodeForces】Educational Codeforces Round 118 (Rated for Div. 2)【A-C】
A. Long Comparison 思路 先判断字符长度 相等的字符长度判断填满0后判断字典序 AC代码 #pragma GCC optimize("Ofast") #pragm ...
- Educational Codeforces Round 118 (Rated for Div. 2) A-C
D的难度跨度太大了,先不写了. A. Long Comparison 给出一个数字x1,后面添加p1个0,一个数字x2,后面添加p2个0.比较两个数字的大小,输出比较的情况. x和p都是10的6次方的 ...
- python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder)、np.mod函数和np.fmod函数对负值的处理方式有差异
python使用numpy的np.fmod函数计算numpy数组除以某一特定数值剩余的余数(remainder).np.mod函数和np.fmod函数对负值的处理方式有差异 目录
- 中国剩余定理(Chinese Remainder Theorem)
中国剩余定理 民间传说着一则故事--"韩信点兵". 秦朝末年,楚汉相争.一次,韩信将1500名将士与楚王大将李锋交战.苦战一场,楚军不敌,败退回营,汉军也死伤四五百人,于是韩信整顿 ...
- CF-1207 F. Remainder Problem(分块)
CF-1207 F. Remainder Problem(分块) 题目链接 题意 一共5e5个数字,两种操作: 1 x y , a[x] += y 2 x y , ∑i∈nai,n∈[1,5e5],n ...
- Linux下启动启动tomcat 服务器报错 The file is absent or does not have execute permission
为什么80%的码农都做不了架构师?>>> Linux下启动启动tomcat 服务器报错 The file is absent or does not have execute ...
- 已解决:Cannot find ./catalina.sh The file is absent or does not have execute permission This file is ne
tomcat直接从windows拷贝到linux下面 bash startup.sh的时候报错 Cannot find ./catalina.sh The file is absent or does ...
- c语言remainder函数,remainder
remainder 在头文件中定义 float remainderf( float x, float y ); (1) (since C99) double remainder( double ...
最新文章
- 卧加加工斜孔怎么计算机械坐标,卧加B轴旋转后坐标怎么计算
- SQL函数--- SQL FIRST()
- 二叉搜索树的最近祖先
- 《从零开始学Swift》学习笔记(Day 42)——构造函数调用规则
- CentOS7 systemctl tomcat常用配置
- 支付宝支付—沙箱环境使用
- proteus里面没有stm32怎么办_嵌入式单片机之stm32串口你懂了多少!!
- 信息学奥赛一本通C++语言——1012:计算多项式的值
- Linux Crontab 定时任务 及 Ubuntu 中cron指令使用
- C/C++字符串处理库
- 如何锻炼一个人处理问题的能力?
- Windows XP操作系统中的禁忌
- MSRA-USTC 计算机科学领域前沿进展新年第一讲
- js 正则中冒号代表什么_是否还在疑惑Vue.js中组件的data为什么是函数类型而不是对象类型...
- Samsung 6818平台首次编译遇到的问题
- python中result的用法_python中result的用法
- python爬取豆瓣读书简单_Python利用lxml模块爬取豆瓣读书排行榜的方法与分析
- 金错刀对话口袋购物王珂:找到痛点,确认卖点,制造爆点!
- 配置 VScode 编辑器 (前端篇)
- 项目经理的岗位职责和要求