Educational Codeforces Round 9 D - Longest Subsequence
思路:枚举lcm, 每个lcm的答案只能由他的因子获得,类似素数筛搞一下。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define pii pair<int,int>
#define piii pair<int, pair<int,int> > using namespace std; const int N = 1e6 + ;
const int M = + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-; int n, m, tot, a[N], cnt[N], id[N]; vector<int> v[N]; void init() {
for(int i = ; i <= m; i++) {
for(int j = i; j <= m; j+= i) {
v[j].push_back(i);
}
}
} int main() {
scanf("%d%d", &n, &m);
for(int i = ; i <= n; i++) {
int x; scanf("%d", &x);
if(x <= m) {
id[tot] = i;
a[tot++] = x;
}
} if(tot == ) {
printf("1 0\n");
} else {
init();
for(int i = ; i < tot; i++) {
cnt[a[i]]++;
} int mx = , ans = ;
for(int i = m; i >= ; i--) {
int ret = ;
for(int t : v[i]) {
ret += cnt[t];
}
if(ret >= mx) {
mx = ret;
ans = i;
}
} printf("%d %d\n", ans, mx);
for(int i = ; i < tot; i++) {
if(ans % a[i] == ) {
printf("%d ", id[i]);
}
}
puts("");
}
return ;
}
/*
*/
Educational Codeforces Round 9 D - Longest Subsequence的更多相关文章
- Educational Codeforces Round 9 D. Longest Subsequence dp
D. Longest Subsequence 题目连接: http://www.codeforces.com/contest/632/problem/D Description You are giv ...
- Codeforces Educational Codeforces Round 5 D. Longest k-Good Segment 尺取法
D. Longest k-Good Segment 题目连接: http://www.codeforces.com/contest/616/problem/D Description The arra ...
- Educational Codeforces Round 32 E. Maximum Subsequence
题目链接 题意:给你两个数n,m,和一个大小为n的数组. 让你在数组找一些数使得这些数的和模m最大. 解法:考虑 dfs但是,数据范围不允许纯暴力,那考虑一下折半搜索,一个从头开始往中间搜,一个从后往 ...
- Educational Codeforces Round 9
Educational Codeforces Round 9 Longest Subsequence 题目描述:给出一个序列,从中抽出若干个数,使它们的公倍数小于等于\(m\),问最多能抽出多少个数, ...
- Educational Codeforces Round 5
616A - Comparing Two Long Integers 20171121 直接暴力莽就好了...没什么好说的 #include<stdlib.h> #include&l ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
随机推荐
- angularJS $watch $apply $digest
看O'Reilly的书看到$watch这部分,不过没看懂,网上很多资料也含糊不清,不过还是找到了几个好的,简单记录一下. 一句话说明,$watch是用来监视变量的,好了直接上代码 <html&g ...
- Twitter.com在用哪些Javascript框架?
我一直在研究 twitter.com 使用的一些 UI 框架.下面是这些框架的清单(大部分是 Javascript 框架).如果你发现有些框架 Twitter 已经没在使用了,请随时告诉我! 测试 J ...
- CSS中的选择器(笔记)
1.通配符选择器(*):通配符选择器是用来选择所有元素,也可以选择某个元素下的所有元素.所有浏览器都支持通配符选择器. ;;} .dome *{padding: 2px;} 2.元素选择器(Ele): ...
- 一个MMORPG的常规技能系统
广义的的说,和战斗结算相关的内容都算技能系统,包括技能信息管理.技能调用接口.技能目标查找.技能表现.技能结算.技能创生体(buff/法术场/弹道)管理,此外还涉及的模块包括:AI模块(技能调用者). ...
- window下卸载MySQL
更多内容推荐微信公众号,欢迎关注: 网上找来的,留在这做个备份. 1.控制面板里的增加删除程序内进行删除 2.删除MySQL文件夹下的my.ini文件,如果备份好,可以直接将文件夹全部删除 3.开始- ...
- linux学习记录.5.git & github
参考 https://www.linuxidc.com/Linux/2016-11/136769.htm 安装 安装 Git: apt-get install git 查看当前版本: git --ve ...
- 如何清理休眠文件(hiberfil.sys)
如果使用了休眠功能,那么打开系统盘就会有一个很大(5.36G)的hiberfil.sys文件,它是将用户正在运行的程序,保存在这里,再启动系统就很快了.如要清理它(不用休眠功能,或者临时腾出空间),可 ...
- OGG-01389 File header failed to parse tokens.
http://blog.csdn.net/zbdba/article/details/44095105; 处理的思路: 1.查看日志 2.在目标端看最新的队列文件的日期,假如没有最新的队列文件就说明源 ...
- 【技巧总结】Penetration Test Engineer[2]-Information gathering
2.信息收集 信息收集是属于前期交互阶段所需要了解的问题. 2.1.前期交互内容 签署授权文件:首要要和受测试方签订授权协议. 划定范围:指定了一个二级域名作为测试目标,那么其他二级域名在测试范围内. ...
- 【Educational Codeforces Round28】
咸鱼选手发现自己很久不做cf了,晚节不保. A.Curriculum Vitae 枚举一下间断点的位置. #include<bits/stdc++.h> using namespace s ...