传送门

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. 关于使用th:text获取不到值

    今天在使用thymeleaf模板引擎整合SpringBoot时,对于从controller层传递过来的参数"message",无法获取. 控制层代码如下: @PostMapping ...

  2. 【Python】简单的脚本,轻松批量修改文件名称

    使用python脚本,批量修改文件夹名称 先创建一些没用的案例文件 import os #创建新文件夹 dir = os.makedirs('D:\\SomeThing\\testfile') #将文 ...

  3. 【Linux】md5sum 生产所有文件的md5值,并对照目标文件是否相同

    现在加入有很多很多文件需要测试md5,想看下是否都传输成功了,如何批量生成文件的md5并且逐条对照呢? 下面来简单介绍下 md5sum这个命令有一个选项"-c" 这个选项的意思是c ...

  4. ping 命令示例

    将下面的代码粘贴到记事本中,然后保存为扩展名为BAT的文件,运行就可以将网段内ping不通的IP地址写入到文本文件IP.txt中. @echo offsetlocal ENABLEDELAYEDEXP ...

  5. ASP.NET Core错误处理中间件[4]: 响应状态码页面

    StatusCodePagesMiddleware中间件与ExceptionHandlerMiddleware中间件类似,它们都是在后续请求处理过程中"出错"的情况下利用一个错误处 ...

  6. Centos7下安装MySQL8.0.23-小白的开始

    首先简单介绍一下什么叫MySQL: 数据库简而言之就是存储数据的仓库,为了方便数据的存储和管理,它将数据按照特定的规律存储在磁盘上.是为了实现一定的目的,按照某种规则组织起来的数据的集合: MySQL ...

  7. 3、wait和waitpid

    1. 函数介绍 wait函数:调用该函数使进程阻塞,直到任意一个子进程结束,或者该进程接收到了一个信号为止,如果该进程没有子进程或该进程的子进程已经结束,wait函数立即返回. waitpid函数:与 ...

  8. Eureka详解系列(二)--如何使用Eureka(原生API,无Spring)

    简介 通过上一篇博客 Eureka详解系列(一)--先谈谈负载均衡器 ,我们知道了 Eureka 是什么以及为什么要使用它,今天,我们开始研究如何使用 Eureka. 在此之前,先说明一点.网上几乎所 ...

  9. JavaScript中函数的this指向!

    JavaScript的this的指向问题! 这是我自己敲的, 报错! <button>点击查看绑定事件的this指向!</button> <script> // 函 ...

  10. 计算机网络安全 —— C# 使用谷歌身份验证器(Google Authenticator)(五)

    一.Google Authenticator 基本概念  Google Authenticator是谷歌推出的一款动态口令工具,旨在解决大家Google账户遭到恶意攻击的问题,在手机端生成动态口令后, ...