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. JAVA WEB ------ 文件下载及导出数据到office Execl表格

    文件下载需要五步: 1.设置文件ContentType类型 // 设置文件ContentType类型,这样设置,会自动判断下载文件类型 response.setContentType("mu ...

  2. Go并发编程(四)

        并发基础   多进程  多线程 基于回调的非阻塞/异步IO     协程  协程  与传统的系统级线程和进程相比,协程的最大优势在于其“轻量级”,可以轻松创建上百万个而不会导致系统资源衰竭, ...

  3. 车牌、手机、身份证、等敏感信息 屏蔽 替换 、中文转unicode编码 函数

    应工作要求,需要对展示的内容进行敏感信息替换.琢磨的一些时间,编写的函数匹配率还是比较高的. 顺便说下思路,使用的是正则匹配替换和字符串替换.函数可以再改进. 先把需要匹配的内容写好相应的正则,然后进 ...

  4. javascript拖拽操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. Android开发-- 使用ADT23 的一些问题

    在使用最新版ADT 23进行android学习时发现一些问题: 1.通过设置intent的action来启动另外一个activity时,会出现No Activity found to handle I ...

  6. Unity绘制Png图片

    using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; publ ...

  7. Java中获取资源文件的方法总结

    这里总结3中方法获取资源文件的 ServletContext Class ClassLoader 文件的位置 1. ServletContext public void doGet(HttpServl ...

  8. Tomcat的目录结构和配置文件详解

    本文转载: https://www.zybuluo.com/1234567890/note/515235 参考帖子: Tomcat(一):基础配置详解 Tomcat服务器中配置多个域名,访问不同的we ...

  9. iText7生成pdf

    1 官网 http://developers.itextpdf.com/itext-java 2 form中加入表格 http://developers.itextpdf.com/content/be ...

  10. RabbitMQ Queue中Arguments属性参数过期队列,过期消息,超时队列的声明

    开发十年,就只剩下这套Java开发体系了 >>>   创建队列时指定参数 队列属性:x-message-ttl 可以控制被publish到queue中的message 被丢弃前能够存 ...