Codeforces Round #441 (Div. 2)【A、B、C、D】
Codeforces Round #441 (Div. 2)
codeforces 876 A. Trip For Meal(水题)
题意:R、O、E三点互连,给出任意两点间距离,你在R点,每次只能去相邻点,要走过n个点,求走过的最短距离。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
int n, a, b, c;
scanf("%d%d%d%d", &n, &a, &b, &c);
if(n==) puts("");
else printf("%d\n", (n-) * min(a, min(b,c)) + min(a,b));
return ;
}
30ms
codeforces 876 B. Divisiblity of Differences(水题)
题意:有N个数,要从中选出K个,要求选出的数相减后都能整除m,求能都选出K个数,并输出选出的数。
题解:容易发现选出的数一定是 对m取余相同 的一类数,将每类数存起来,大于K个则输出这一类。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const int N = ;
int a[N];
vector<int>c[N];
int main() {
int n, k, m, i, j, f = ;
for(i = ; i < N; ++i) c[i].clear();
scanf("%d%d%d", &n, &k, &m);
for(i = ; i <= n; ++i) {
scanf("%d", &a[i]);
c[a[i]%m].push_back(i);
}
for(i = ; i < m; ++i) {
if(c[i].size() >= k) {
puts("Yes"); f = ;
for(j = ; j < k-; ++j) printf("%d ", a[c[i][j]]);
printf("%d\n", a[c[i][k-]]);
break;
}
}
if(!f) puts("No");
return ;
}
61ms
codeforces 875 A. Classroom Watch(暴力)
题意:给你n要求有几个x满足 x加上x的各个数位之和等于n,比如:x=100a+10b+c,n=x+a+b+c。
题解:暴力,枚举i(各个数位之和),令x=n-i再检验x是否满足题意。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[];
int main() {
int n, i, j, x, y, cnt = ;
scanf("%d", &n);
for(i = min(n-,); i >= ; --i) {
x = n - i; y = ;
while(x) {y += x%; x /= ;}
if(y == i) a[cnt++] = n-i;
}
printf("%d\n", cnt);
for(i = ; i < cnt; ++i) printf("%d\n", a[i]);
return ;
}
15ms
codeforces 875 B. Sorting the Coins(模拟)
题意:一排n个位置,每次操作在p[i]位置放硬币,从左往右看,如果第i个位置有硬币,第i+1位置没有,则交换硬币(可以看看题目Note就好懂了,X0X0->0X0X是换了两次硬币,但这是一步,从左往右看一次是一步),直到无法再交换位置,求每次操作要几步。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = ;
int a[N];
int main() {
int n, i, x;
scanf("%d", &n);
int m = n + ;
printf("");
for(i = ; i <= n; ++i) {
scanf("%d", &x);
a[x] = ;
while(a[m-]) m--;
printf(" %d", i-n+m);
}
return ;
}
155ms
不补题了,看不透英语。。。
Codeforces Round #441 (Div. 2)【A、B、C、D】的更多相关文章
- Codeforces Round #441 (Div. 2)
Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的 ...
- Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...
- Codeforces Round #434 (Div. 2)【A、B、C、D】
Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #435 (Div. 2)【A、B、C、D】
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...
- Codeforces Round #440 (Div. 2)【A、B、C、E】
Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...
- Codeforces Round #439 (Div. 2)【A、B、C、E】
Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...
- [日常] Codeforces Round #441 Div.2 实况
上次打了一发 Round #440 Div.2 结果被垃圾交互器卡掉 $200$ Rating后心情复杂... 然后立了个 Round #441 要翻上蓝的flag QAQ 晚饭回来就开始搞事情, 大 ...
- Codeforces Round #430 (Div. 2) 【A、B、C、D题】
[感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...
随机推荐
- Android组件--意图(Intent)
1. 隐示调用和显示调用 参考资料:http://blog.csdn.net/harvic880925/article/details/38399723 1.概念 1). 显式意图: 能从intent ...
- MySQL字符串函数:字符串截取
MySQL 字符串截取函数:left(), right(), substring(), substring_index().还有 mid(), substr().其中,mid(), substr() ...
- T4模板的一些配置(从EF数据更新)
<#@ template debug="false" hostspecific="false" language="C#" #> ...
- Cheatsheet: 2018 01.01 ~ 02.28
JAVA How to Improve the Performance of a Java Application Java Memory Management Writing Java Micros ...
- 撩课-Web大前端每天5道面试题-Day16
1.for循环中的作用域问题? 写出以下代码输出值,尝试用es5和es6的方式进行改进输出循环中的i值. ; i<=; i++) { setTimeout(function timer() { ...
- IntelliJ IDEA 2018.3 安装+永久激活[Windows]
IntelliJ IDEA 作为一个优秀的Java开发环境,深受许多开发者喜爱,但是它的价格却贵得让人无法接受,这篇文章将介绍永久激活IntelliJ IDEA的方法(使用破解补丁). 系统环境:Wi ...
- Oracle SQL developer 连接 MySQL 数据库安装配置
1. 下载 JDBC driver for MySQL 下载链接: https://dev.mysql.com/downloads/connector/j/ 下载成功后,解压缩,得到 mysql jd ...
- poj 1833 排列 STL 全排列公式
排列 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 15173 Accepted: 6148 Description 题 ...
- MySQL数据库更改默认引擎为Innodb【配置】
InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定. 基本的差别为:MyISAM类型不支持事务处理等高级处理,而InnoDB类型支持.MyIS ...
- Visual Studio 2015 + Update 1
Visual Studio 2015是一个基本完整的开发工具集,它包括了整个软件生命周期中所需要的大部分工具,如UML工具.代码管控工具.集成开发环境(IDE)等等.所写的目标代码适用于微软支持的所有 ...