传送门

A - ABC Swap

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int x,y,z;
25
26 int main() {
27 ios::sync_with_stdio(false);
28 cin>>y>>z>>x;
29 printf("%d %d %d\n",x,y,z);
30
31 return 0;
32 }

B - Popular Vote

按照题目意思直接写

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int n;
25 double m;
26 double a[N];
27 double sum=0;
28 int main() {
29 ios::sync_with_stdio(false);
30 cin>>n>>m;
31 for(int i=0;i<n;++i){
32 cin>>a[i];
33 sum+=a[i];
34 }
35 sort(a,a+n);
36
37 double check=sum/(4*m);
38 int cnt=0;
39 for(int i=n-1;i>=0;--i){
40 if(a[i]>=check) cnt++;
41 if(cnt==m){
42 printf("Yes\n");
43 return 0;
44 }
45 }
46 printf("No\n");
47
48
49 return 0;
50 }

C - Replacing Integer

题意:给你两个整数x和K,每次用abs(x-K)替换x,求替换后x的最小值

题解:如果x%k==0,那么最小值就是0,否则取x除K的余数和K减其余数的最小值即可

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 ll n,k;
25
26 int main() {
27 ios::sync_with_stdio(false);
28 cin>>n>>k;
29 if(n%k==0){
30 printf("0\n");
31 }
32 else{
33 printf("%lld\n",min(n%k,k-(n%k)));
34 }
35
36 return 0;
37 }

D - Lunlun Number

题意:对于某个数X,如果它的每一位数的差的绝对值都<=1,那么这个数就是一个“lunlun num”,现在求第k小的“lunlun num”是多少

题解:用一个单调队列来存"lunlun num",每次取一个数,将它当前个位的数 +1,+0,-1,添加到它新的个位即可,要注意特判个位是0和9的时候,分别不能放-1和+1;

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int k;
25 ll q[N],hh=1,tt=0;
26
27 int main() {
28 ios::sync_with_stdio(false);
29 cin>>k;
30 if(k<=12){
31 printf("%d\n",k);
32 return 0;
33 }
34
35 for(int i=1;i<=9;++i) q[++tt]=i;
36
37 int cnt=0;
38 ll ans;
39 while(cnt!=k){
40 ll now=q[hh];
41 hh++;
42 ll res=now%10;
43
44 if(res!=0) q[++tt]=now*10+res-1,cnt++;
45 if(cnt==k-10+1){
46 ans=q[tt];
47 break;
48 }
49 q[++tt]=now*10+res,cnt++;
50 if(cnt==k-10+1){
51 ans=q[tt];
52 break;
53 }
54 if(res!=9) q[++tt]=now*10+res+1,cnt++;
55 if(cnt==k-10+1){
56 ans=q[tt];
57 break;
58 }
59 }
60 printf("%lld\n",ans);
61
62
63 return 0;
64 }

E - Yutori

题意:你想在N天中工作k天,但你每工作一天就要休息c天,给你一个字符串s,只有s[i]=‘o'的时候,你才能在第i天工作,所以在哪天工作,你有多种选择,求你在这么多天中有哪几天是必须要工作的

题解:(贪心)首先从头正的遍历一边,如果能工作那么就L[x]++,这样一定能确定我们所选的工作日都是最早的,然后再反的遍历一边,如果能工作就R[x]++,得到的所有工作日一定是最晚的,那对于任意的i,如果有L[i]==R[i],这一天就一定会选.

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int n,k,c;
25 string s;
26 vector<int> L,R;
27
28 int main() {
29 ios::sync_with_stdio(false);
30 cin>>n>>k>>c>>s;
31
32 for(int i=0;i<s.size();++i){
33 if(s[i]=='o') L.pb(i),i+=c;
34 if(L.size()==k) break;
35 }
36 for(int i=s.size()-1;i>=0;--i){
37 if(s[i]=='o') R.pb(i),i-=c;
38 if(R.size()==k) break;
39 }
40
41 for(int i=0;i<k;++i){
42 if(L[i]==R[k-i-1])
43 printf("%d\n",L[i]+1);
44 }
45
46 return 0;
47 }

Atcoder ABC161 A~E的更多相关文章

  1. AtCoder Beginner Contest 161

    比赛链接:https://atcoder.jp/contests/abc161/tasks AtCoder Beginner Contest 161 第一次打AtCoder的比赛,因为是日本的网站终于 ...

  2. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  3. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  4. AtCoder Regular Contest 082

    我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...

  5. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

  6. AtCoder Regular Contest 076

    在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...

  7. AtCoder Grand Contest 016

    在雅礼和衡水的dalao们打了一场atcoder 然而窝好菜啊…… A - Shrinking 题意:定义一次操作为将长度为n的字符串变成长度n-1的字符串,且变化后第i个字母为变化前第i 或 i+1 ...

  8. AtCoder Beginner Contest 069【A,水,B,水,C,数学,D,暴力】

    A - K-City Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement In K-city, ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle

    https://beta.atcoder.jp/contests/abc075/tasks/abc075_d 题意: 给出坐标平面上n个点的坐标,要求找到一个面积最小的矩形使得这个矩形的边界加上内部的 ...

随机推荐

  1. python模块详解 | shutil

    简介: shutil是python的一个内置模块,提供了许多关于文件和文件集合的高级操作,特别提供文件夹与文件操作.归档操作了支持文件复制和删除的功能. 文件夹与文件操作: copyfileobj(f ...

  2. 深入汇编指令理解Java关键字volatile

    volatile是什么 volatile关键字是Java提供的一种轻量级同步机制.它能够保证可见性和有序性,但是不能保证原子性 可见性 对于volatile的可见性,先看看这段代码的执行 flag默认 ...

  3. ES6 自定义一个实现了Iterator接口的对象

    参考资料 var obj = { data: [1,2,3,4,5], // 这里实际上就是去定义如何实现Iterator接口 [Symbol.iterator](){ const that = th ...

  4. 在 Azure 上执行一些简单的 python 工作

    1. 公司禁用了 python 我的主业是桌面开发,偶尔也需要搞搞数据和算法.最近在用 python 处理一些工作,正搞得热火朝天,突然 python 就不能用了,一查记录原来是 IT 管理员禁止我使 ...

  5. 容器编排系统K8s之HPA资源

    前文我们了解了用Prometheus监控k8s上的节点和pod资源,回顾请参考:https://www.cnblogs.com/qiuhom-1874/p/14287942.html:今天我们来了解下 ...

  6. 什么是xss攻击

    概述: XSS攻击是Web攻击中最常见的攻击方法之一,它是通过对网页注入可执行代码且成功地被浏览器 执行,达到攻击的目的,形成了一次有效XSS攻击,一旦攻击成功,它可以获取用户的联系人列 表,然后向联 ...

  7. MySQL下载与安装教程

    一,下载篇 1,首先访问MySQL官网下载页,https://dev.mysql.com/downloads/mysql/ 如果是MAC系统,操作系统请选择macOS,Windows则选择Window ...

  8. STM32驱动LCD原理

    TFTLCD即薄膜晶体管液晶显示器.它与无源TN-LCD.STN-LCD的简单矩阵不同,它在液晶显示屏的每一个像素上都设置有一个薄膜晶体管(TFT),可有效地克服非选通时的串扰,使显示液晶屏的静态特性 ...

  9. 如何封装Promise对象?

    最近看到了一个有趣的Promise的方法,这里记录下来 <script> class MyPromise { constructor(executor) { // 初始化state赋值为p ...

  10. 深入理解 MySQL 索引底层原理

    https://mp.weixin.qq.com/s/qHJiTjpvDikFcdl9SRL97Q