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 题解 直接 ...
随机推荐
- ZOJ 2702 Unrhymable Rhymes
Unrhymable Rhymes Time Limit:10000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu De ...
- hdoj--2036--改革春风吹满地(数学几何)
改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- windows 快捷调用
win + x:系统常用管理工具: win + r,或者按下 windows 键,在输入框中输入: services.msc:服务管理: diskmgmt.msc:磁盘管理: devmgmt.msc: ...
- Keyboard input
Keyboard input Python provides a build-in function called raw_input (in version 2.x) that gets input ...
- PullToRefreshListView的刷新和加载的控制
pullToRefresh.setMode(Mode.BOTH); Mode.BOTH:同时支持上拉下拉 Mode.PULL_FROM_START:只支持下拉Pulling Down M ...
- 求推荐go语言开发工具及go语言应该以哪种目录结构组织代码?
go语言的开发工具推荐? go语言开发普通程序及开发web程序的时候,应该以哪种目录结构组织代码? 求推荐go语言开发工具及go语言应该以哪种目录结构组织代码? >> golang这个答案 ...
- cuda thrust函数首次调用耗费时间比后续调用长原因
lazy context initialisation. stackoverflow
- codeforces 445 B DZY Loves Chemistry【并查集】
题意:给出n种化学物质,其中m对会发生化学反应,每次加入化学物质进去的时候, 如果有能够和它发生反应的,危险值就乘以2,问怎样的放入顺序使得危险值最大 将这m对会反应的用并查集处理,统计每个连通块里面 ...
- WIFI 概览
概览 Android 提供默认 Android 框架实现,其中包括对各种 WLAN 协议和模式的支持,这些协议和模式包括: WLAN 基础架构 (STA) 网络共享模式或仅限本地模式下的 WLAN ...
- Vue总结(三)
Vue 实例还暴露了一些有用的实例属性与方法.它们都有前缀 $,以便与用户定义的属性区分开来. var App = new Vue({ el: "#root", data: { m ...