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】的更多相关文章

  1. Codeforces Round #441 (Div. 2)

    Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的 ...

  2. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  3. 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. 题解:答案就是 ...

  4. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  5. Codeforces Round #435 (Div. 2)【A、B、C、D】

    //在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...

  6. Codeforces Round #440 (Div. 2)【A、B、C、E】

    Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...

  7. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  8. [日常] Codeforces Round #441 Div.2 实况

    上次打了一发 Round #440 Div.2 结果被垃圾交互器卡掉 $200$ Rating后心情复杂... 然后立了个 Round #441 要翻上蓝的flag QAQ 晚饭回来就开始搞事情, 大 ...

  9. 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.直接暴力判断即 ...

随机推荐

  1. Delphi 枚举所有进程

    通过进程快照枚举所有进程,关于进程快照,在Delphi5开发人员指南中有说明,当然也可以百度一下用法. 使用进程快照CreateToolhelp32Snapshot,必须uses TlHelp32单元 ...

  2. js 列表选择

    首选定义数组,然后进行操作时遍历数组获取选中值 function getSelect(userId) { //var userId = userCheckBox.value; //标记删除还是添加 v ...

  3. Shell脚本编写1

    1.shell操作系统与外部最主要的接口就叫做shell.shell是操作系统最外面的一层.shell管理你与操作系统之间的交互:等待你输入,向操作系统解释你的输入,并且处理各种各样的操作系统的输出结 ...

  4. TRUNCATE TABLE 与 DELETE的区别

    delete from aatruncate table aa 区别1.delete from后面可以写条件,truncate不可以2.delete from记录是一条条删的,所删除的每行记录都会进日 ...

  5. 第6天:数据Array

    数组Array every() 方法测试数组的所有元素是否都通过了指定函数的测试. array.every callback[, thisArg] callback 被调用时传入三个参数:元素值,元素 ...

  6. mysql:名次排名 (并列与不并列)

    http://www.cnblogs.com/zengguowang/p/5541431.html sql语句查询排名 思路:有点类似循环里面的自增一样,设置一个变量并赋予初始值,循环一次自增加1,从 ...

  7. flask笔记三:flask-login插件的使用

    flask-login插件的使用 安装: pip install flask-login 初始化LoginManager ##############LoginManager设置########### ...

  8. redis 学习(一)

    一.Redis概述 1.什么是NoSql NoSQL(NoSQL = Not Only SQL ),意即“不仅仅是SQL”,它泛指非关系型的数据库. 随着互联网2003年之后web2.0网站的兴起,传 ...

  9. CodeForces 598A(水)

    还是要注意int和long long的范围,以及double型的问题 pow函数经常会报一个double型的错,参考这篇文章 http://blog.csdn.net/lawrencesgj/arti ...

  10. js array copy method

    //浅拷贝: let arr=[1,2,3,4] let arr2=arr arr[3]=0 console.log(arr,arr2) //output: (4) [1, 2, 3, 0] (4) ...