Codeforces Round #240 (Div. 2) 题解
A: 1分钟题,往后扫一遍
int a[MAXN];
int vis[MAXN];
int main(){
int n,m;
cin>>n>>m;
MEM(vis,);
for(int i = ; i <= m ; i++) {
cin>>a[i];
for(int j = a[i] ; j <= n ; j++){
if(vis[j] == ){
vis[j] = a[i];
}
}
}
for(int i = ; i <= n ; i++){
cout<<vis[i]<<" ";
}cout<<endl;
return ;
}
B: 给a,b,n...求x<=n 且floor(x*a/b)最大时的,x的最大值 3分钟题
int x[MAXN];
int main(){
LL n,a,b;
cin>>n>>a>>b;
for(int i = ; i < n ; i++){
cin>>x[i];
LL p = (x[i]*a)/b;
if((p*b)%a == ){
cout<<x[i]-(p*b)/a<<" ";
}else
cout<<x[i]-(p*b)/a-<<" ";
}
cout<<endl; return ;
}
C: 各种特判...前两个保证是x和2x,剩下的自然gcd全是1就行了..那么显然相邻的gcd一定是1...wa了3次我太蠢了
int main(){
int n,k;
while(cin>>n>>k){
int m = n/;
if(n == && k == ){
cout<<""<<endl;
continue;
}
if(m > k || n == || k == ){
cout<<"-1"<<endl;
continue;
}
int x = k-m+;
int y = x*;
cout<<x<<" "<<y<<" ";
int cnt = ;
for(int i = ; i < m- ; i++){
while(cnt == x || cnt+ == x || cnt == y || cnt+ == y) cnt++;
cout<<cnt<<" "<<cnt+<<" ";
cnt+=;
}
while(cnt == x || cnt+ == x || cnt == y || cnt+ == y) cnt++;
if(n% == ) cout<<cnt<<endl;
else cout<<endl;
}
return ;
}
D: dp , dp[i][j] 表示 第i位为j的 方案数 那么类似素数筛搞一遍, 每个状态只能由i-1且为j的约数 转移过来...打一下就是O(n^2lnn)
LL dp[][];
int main(){
int n,k;
while(cin>>n>>k){
MEM(dp,);
for(int i = ; i <= n ; i++){
dp[][i] = ;
}
for(int i = ; i <= k ; i++){
for(int j = ; j <= n ; j++){
for(int x = j ; x <= n ; x+=j){
dp[i][x] = (dp[i][x] + dp[i-][j]) % MOD;
}
}
}
LL res = ;
for(int i = ; i <= n ; i++){
res = (res + dp[k][i])% MOD;
}
cout<<res<<endl;
}
return ;
}
E: 并归搞吧...还有直接暴力sort过的...CF机器真快...todo一下
+182...偶尔爆发一下...
Codeforces Round #240 (Div. 2) 题解的更多相关文章
- Codeforces Round #182 (Div. 1)题解【ABCD】
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #665 (Div. 2) 题解
Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...
- Codeforces Round #160 (Div. 1) 题解【ABCD】
Codeforces Round #160 (Div. 1) A - Maxim and Discounts 题意 给你n个折扣,m个物品,每个折扣都可以使用无限次,每次你使用第i个折扣的时候,你必须 ...
- Codeforces Round #383 (Div. 2) 题解【ABCDE】
Codeforces Round #383 (Div. 2) A. Arpa's hard exam and Mehrdad's naive cheat 题意 求1378^n mod 10 题解 直接 ...
随机推荐
- Android 取得 ListView中每个Item项目的值
首先我们须要创建 ListView .这里假定我们已经创建好了而且使用SimpleAdapter设置好了adapter数据,看一下我们的adapter ArrayList<HashMap< ...
- 一、奇妙插件Tampermonkey的简单安装教程
奇妙插件Tampermonkey的简单安装教程 1.下载 对于浏览器而言,一般的功能并不能满足"特殊用户的需求".这时候就须要插件来帮忙了.那么讲到插件的支持多又常见的浏览器必定要 ...
- Html学习(三) 分类学习
代码: <h1>这是一级分类吗</h1> <h2>这是二级分类吗</h2> <h3>这是三级分类吗 </h3> 效果: 介绍: ...
- HDU 4930 Fighting the Landlords(暴力枚举+模拟)
HDU 4930 Fighting the Landlords 题目链接 题意:就是题中那几种牌型.假设先手能一步走完.或者一步让后手无法管上,就赢 思路:先枚举出两个人全部可能的牌型的最大值.然后再 ...
- Thinkphp 无法使用->order() 排序的两种解决的方法!
使用ThinkPHP,却发现无法使用->order($order)来排序. $order = " info.date2 desc "; 非常遗憾的是这样写结果order却变成 ...
- Innosetup
卸载的同时删除日志,卸载的时候判断程序是否正在运行,regsvr32 1.卸载程序的时候如何判断程序是否正在运行 http://bbs.csdn.net/topics/370097914 2.强制删除 ...
- 递归神经网络——就是解决AST这样的问题
原文:https://zybuluo.com/hanbingtao/note/626300 有时候把句子看做是词的序列是不够的,比如下面这句话『两个外语学院的学生』: 上图显示了这句话的两个不同的语法 ...
- DGA特征挖掘
摘自:https://paper.seebug.org/papers/Archive/drops2/%E7%94%A8%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E8%A ...
- array_unique和array_flip 这两个函数的区别
array_unique和array_flip 这两个函数的区别 标签(空格分隔): php array_unique 和 array_flip 验证 1 没有排序的数组 2 array_unique ...
- BZOJ 4551 HEOI 2016 树 (并查集)
思路: 考虑时光倒流 这不就是并查集裸题了-----. //By SiriusRen #include <cstdio> #include <cstring> #include ...