Codeforces Round #441A+B+C
来源:互联网 发布:最准彩票预测软件 编辑:程序博客网 时间:2024/06/07 02:03
打完这场cf,终于认清了自己的英语有多么的差,还是好好读题,被自己菜到了
A
题意,给你三个人的房子他们之间的距离,某某某现在Now he is in the Rabbit's house and has a meal for the first time,在这个位置,你安排下,去其他人家吃蜂蜜,每一家此一次就得离开,必须在别人家吃完才能回来,问你他需要走的最短距离
My ugly code、
#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <string>using namespace std;int n,a,b,c;int main(){while(~scanf("%d",&n)){scanf("%d%d%d",&a,&b,&c);if(n==1){printf("0\n");continue ;}int ans=0;if( a > b){ans=b + (n-2)*min(b,c);}else{ans=a+(n-2)*min(a,c);}printf("%d\n",ans);}return 0;}
B,大体题意就是让你在一row数里面,挑出来一系列的数,他们俩两做差,在对m取模等于0,其实提示对很明显了,(a-b)%m==0也就是a%m-b%m==0,就是a%m=b%m,hhhhhhhhhh
My ugly code
//// main.cpp// C_workspace//// Created by ldu on 2017/10/13.// Copyright © 2017年 ldu. All rights reserved.//#include <iostream>#include <cmath>#include <cstring>#include <string>#include <cstdio>#include <algorithm>#include <queue>using namespace std;const int maxn=1e5+10;int n,m,k;int a[maxn];vector<int> b[maxn];int main() { while (~scanf("%d%d%d",&n,&k,&m)) { for(int i=0;i<=m;i++){ b[i].clear(); } for(int i=1;i<=n;i++){ scanf("%d",&a[i]); b[a[i]%m].push_back(a[i]); } int flag=0; for(int i=0;i<m;i++){ if (b[i].size()>=k) { printf("Yes\n"); printf("%d",b[i][0]); for(int j=1;j<k;j++){ printf(" %d",b[i][j]); } printf("\n"); flag=1; break ; } } if(!flag) printf("No\n"); } return 0;}
最后来吐槽一下c题,就是让你找个数,他加上他的每一位,最后等于给你的n
My ugly code
//// main.cpp// C_workspace//// Created by ldu on 2017/10/13.// Copyright © 2017年 ldu. All rights reserved.//#include <iostream>#include <cmath>#include <cstring>#include <string>#include <cstdio>#include <algorithm>#include <queue>using namespace std;const int maxn=1e5+10;int n,m,k;int a[maxn];vector<int> b[maxn];int main() { while (~scanf("%d%d%d",&n,&k,&m)) { for(int i=0;i<=m;i++){ b[i].clear(); } for(int i=1;i<=n;i++){ scanf("%d",&a[i]); b[a[i]%m].push_back(a[i]); } int flag=0; for(int i=0;i<m;i++){ if (b[i].size()>=k) { printf("Yes\n"); printf("%d",b[i][0]); for(int j=1;j<k;j++){ printf(" %d",b[i][j]); } printf("\n"); flag=1; break ; } } if(!flag) printf("No\n"); } return 0;}
阅读全文
0 0
- Codeforces Round #441A+B+C
- Codeforces Round #441 (Div. 2) A,B,C
- Codeforces Round #441 (Div. 2)A + B + C
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #1 A B C
- Codeforces Beta Round #2 A B C
- Codeforces Round #231 A,B,C
- Codeforces Round #278(Div2) A B C
- Codeforces Round #300 A B C
- Educational Codeforces Round 8 (A B C)
- Codeforces Round #351 A B C D
- Codeforces Round #377 A.B.C.D
- Codeforces Round #399 (A,B,C)
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- Codeforces Beta Round #1 A,B,C
- 2017东北长春第十届国际装备制造业博览会、2017第十三届汽车零部件展览会会刊(参展商名录)
- Python笔记Day1
- Spring IOC
- 量化投资:第2节 择时策略的优化
- css布局
- Codeforces Round #441A+B+C
- iOS 实现赋值粘贴
- EditText弹出输入框,换行变成搜索
- 前端开发:艺术字体ttf资源文件
- 欢迎使用CSDN-markdown编辑器
- struts的日期处理(后台Date或者Timestamp)前台显示
- bzoj 2648 (kdtree模板题)
- 总结,报告太麻烦?思维导图帮你忙
- delphi中后缀名为:.dpr,.dfm,.pas,.cfg,.dof,dcu,.res.ddp,分别表示是什么文件?有什么用处?