A. Trip For Meal

题目链接:http://codeforces.com/contest/876/problem/A

题目意思:现在三个点1,2,3,1-2的路程是a,1-3的路程是b,2-3的路程是c,从1点开始,小熊维尼在1点吃过一次蜂蜜了,但是他要吃n次蜂蜜,每次他离开一个地方以后这个地方的蜂蜜就会自动补充,问最少需要走多少距离。

题目思路:如果n=1,那么就是0,如果n等于2,那么答案说就是min(a,b),如果n>2,答案就是min(a,b)+(n-2)*min(a,b,c);

代码:

 //Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
const long long mod=1e9+;
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
int main() {
ios::sync_with_stdio(false);cin.tie();
int n,a,b,c;
cin>>n>>a>>b>>c;
int k=min(a,b);
k=min(k,c);
if(n==) {cout<<<<endl;return ;}
if(k==a||k==b){cout<<(n-)*k<<endl;return ;}
cout<<min(a,b)+(n-)*k<<endl;
return ;
}

B. Divisiblity of Differences

题目链接:http://codeforces.com/contest/876/problem/B

题目意思:现在有n个数,问是否可以从里面找出k个数,那么这k个数两两之间的差的绝对值是m的倍数。

题目思路:如果两个数的差是m的倍数,那么这两个数%m以后的余数相同,所以把所有数根据%m以后余数的不同分类,然后看是不是又哪一类中的元素超过k个。

代码:

 //Author: xiaowuga
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define MAX INT_MAX
#define mem(s,ch) memset(s,ch,sizeof(s))
const long long N=;
const long long mod=1e9+;
typedef long long LL;
typedef int II;
typedef unsigned long long ull;
#define nc cout<<"nc"<<endl
#define endl "\n"
map<int,int>a;
vector<int>G[N];
int main() {
ios::sync_with_stdio(false);cin.tie();
int n,k,m;
int t;
cin>>n>>k>>m;
int ct=;
for(int i=;i<n;i++){
cin>>t;
int x=t%m;
if(a.count(x)==) a[x]=ct++;
G[a[x]].push_back(t);
}
int ans=-;
for(int i=;i<ct;i++){
if(G[i].size()>=k){
ans=i;
break;
}
}
if(ans==-) {cout<<"No"<<endl;return ;}
else{
cout<<"Yes"<<endl;
for(int i=;i<k;i++){
cout<<G[ans][i]<<' ';
}
}
cout<<endl;
return ;
}

C. Classroom Watch

题目链接:http://codeforces.com/contest/876/problem/C

题目意思:现在有一个数

Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)的更多相关文章

  1. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) D. Sorting the Coins

    http://codeforces.com/contest/876/problem/D 题意: 最开始有一串全部由"O"组成的字符串,现在给出n个数字,指的是每次把位置n上的&qu ...

  2. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) C. Classroom Watch

    http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: ...

  3. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) B. Divisiblity of Differences

    http://codeforces.com/contest/876/problem/B 题意: 给出n个数,要求从里面选出k个数使得这k个数中任意两个的差能够被m整除,若不能则输出no. 思路: 差能 ...

  4. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) A. Trip For Meal

    http://codeforces.com/contest/876/problem/A 题意: 一个人一天要吃n次蜂蜜,他有3个朋友,他第一次总是在一个固定的朋友家吃蜂蜜,如果说没有吃到n次,那么他就 ...

  5. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) E. National Property(2-sat)

    E. National Property time limit per test 1 second memory limit per test 512 megabytes input standard ...

  6. Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) F. High Cry(思维 统计)

    F. High Cry time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...

  7. ACM-ICPC (10/16) Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)

    A. Trip For Meal Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. ...

  8. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth

    http://codeforces.com/contest/1064/problem/D 向上/向下加0,向左/右加1, step = 0,1,…… 求的是最少的步数,所以使用bfs. step=k ...

  9. Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) D. Labyrinth(重识搜索)

    https://codeforces.com/contest/1064/problem/D 题意 给你一个有障碍的图,限制你向左向右走的次数,问你可以到达格子的个数 思路 可以定义状态为vi[x][y ...

随机推荐

  1. 【虚拟机】安装vmtools之后任然不能在虚拟机和主机之间复制粘贴的问题

    一.卸载 ../bin/vmware-uninstall-tools.pl rm -rvf /usr/lib/vmware-tools apt-get install open-vm-tools-de ...

  2. DrawCall 优化 .

    unity3D 对于移动平台的支持无可厚非,但是也有时候用Unity3D 开发出来的应用.游戏在移动终端上的运行有着明显的效率问题,比如卡.画质等各种问题.自己在做游戏开发的时候偶有所得.对于主要影响 ...

  3. read by other session 等待事件。

    今天是2014-01-06,从今天开始,打算春节之前每天学习一个等待事件,今天就记录一下read by other session这个等待事件笔记. 什么是read by other session? ...

  4. python爬虫---->scrapy的使用(一)

    这里我们介绍一下python的分布式爬虫框架scrapy的安装以及使用.平庸这东西犹如白衬衣上的污痕,一旦染上便永远洗不掉,无可挽回. scrapy的安装使用 我的电脑环境是win10,64位的.py ...

  5. gulp生成发布包脚本

    var formPost = require('./tools/submit.js');var gulp = require('gulp'), zip = require('gulp-zip'), h ...

  6. C陷阱与缺陷读书笔记

    2.1理解函数声明 这一章仔细分析了(*(void(*)())0)();这条语句的含义,并且提到了typedef的一种函数指针类型定义的用法. 我们经常用到的typedef用法是用于指定结构体的类型, ...

  7. linux下php redis扩展安装

    sudo tar vxzf redis-2.2.7.tgz cd redis-2.2.7 执行sudo /data/service/php54/bin/phpize 在目录下生成配置文件 sudo . ...

  8. [BeiJing2011]元素[贪心+线性基]

    2460: [BeiJing2011]元素 Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 1245  Solved: 652[Submit][Stat ...

  9. 盘古分词修改支持mono和lucene.net3.03

    盘古分词平台兼容性 在使用Lucece.net,需要一个中文的分词组件,比较好的是盘古分词,但是我希望能够在mono的环境下运行,就使用moma检查了一下盘古分词 Assembly Version M ...

  10. 【CF316G3】Good Substrings 后缀自动机

    [CF316G3]Good Substrings 题意:给出n个限制(p,l,r),我们称一个字符串满足一个限制当且仅当这个字符串在p中的出现次数在[l,r]之间.现在想问你S的所有本质不同的子串中, ...