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.直接暴力判断即 ...
随机推荐
- zabbix与nagios八项重要对比 结论根据业务环境需求决定
1.web功能: Nagios简单直观,报警与数据都在同一页面,***.红色即为问题项.Nagios web端不要做任何配置. Zabbix监控数据与报警是分开的,查看问题项需要看触发器,查看数据在最 ...
- 十八、fork/join框架
一.简介 在hadoop的分布式计算框架MapReduce中,会经过两个过程Map过程和reduce过程.Map过程将任务并行计算,reduce汇总并行计算的结果,如图: MapReduce是在分布式 ...
- (JSP)关于手机端(尤其是苹果手机)pdf文件无法打开的解决方案
流的方式下载附件 <!-- @author :daisy @date : 2011-12-04 @note : 从数据库中读取BLOB图片显示 --> <%@page import= ...
- LeetCode 第二天后续(两数相加 python3)
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # sel ...
- CodeForces 598A(水)
还是要注意int和long long的范围,以及double型的问题 pow函数经常会报一个double型的错,参考这篇文章 http://blog.csdn.net/lawrencesgj/arti ...
- POJ P2318 TOYS与POJ P1269 Intersecting Lines——计算几何入门题两道
rt,计算几何入门: TOYS Calculate the number of toys that land in each bin of a partitioned toy box. Mom and ...
- java截取字符串
public class Temp { public static void main(String[] args) { String a="dsadgafa34"; System ...
- PHP学习笔记(二) ---- PHP数据类型
PHP __数据结构类型 一.php 中的八种数据类型 1.四种标量类型 Boolean (布尔类型): true or false,多用于条件判断. 实例: <?php $x = &qu ...
- Drupal7安装注意事项
1.在php.ini中将max_execution_time = 2400,memory_limit = 256M
- react生命周期es6
基本函数有 import React from 'react' export default class MyClass extends React.Component { constructor(p ...