目录

A

签到

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std; const int N=5e5+10; void solve()
{
string str;cin>>str;
bool st=true;
rep(i,0,str.size()-1)
{
if(!i)
{
if(str[i]>='A'&&str[i]<='Z') continue;
else
{
cout<<"No"<<endl;
return;
}
}
if(str[i]>='a'&&str[i]<='z') continue;
else
{
cout<<"No"<<endl;
return;
}
}
cout<<"Yes"<<endl;
} int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}

B

签到题

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std; const int N=5e5+10; void solve()
{
string str;cin>>str;
map<char,int>cnt;
for(auto c:str) cnt[c]++;
char c;
int k=0;
for(auto it:cnt)
{
if(it.y>k)
{
k=it.y;
c=it.x;
}
}
cout<<c<<endl;
} int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}

C题

观察到数据范围n只有10,想到去枚举a的数量然后去看b最多能做多少。

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std; const int N=20;
int c[N],a[N],b[N],n; bool check1(int x)
{
rep(i,1,n) if(x*a[i]>c[i]) return false;
return true;
} void solve()
{
cin>>n;
int sa=0,sb=0,sc=0;
rep(i,1,n) cin>>c[i],sc+=c[i];
rep(i,1,n) cin>>a[i],sa+=a[i];
rep(i,1,n) cin>>b[i],sb+=b[i];
int ans=0;
rep(gg,0,1e6)
{
if(!check1(gg)) break;
int kk=1e6;
rep(i,1,n)
{
if(b[i]==0) continue;
int xx=c[i]-a[i]*gg;
xx/=b[i];
kk=min(kk,xx);
}
ans=max(ans,gg+kk);
}
cout<<ans<<endl;
} int main()
{
IOS
// freopen("1.in", "r", stdin);
// int t;
// cin>>t;
// while(t--)
solve();
return 0;
}

D题

也很巧妙,贡献法的思想。

对于每一个路径计算他对不同断桥产生的贡献。

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
using namespace std; const int N=1e6+10; ll n,m,x[N],cf[N]; ll dist(ll x,ll y)
{
if(x<=y) return y-x;
else return n-(x-y);
} void add(ll x,ll y,ll d)
{
if(x<=y)
{
cf[x]+=d;
cf[y]-=d;
}
else
{
cf[x]+=d;
cf[n+1]-=d;
cf[1]+=d;
cf[y]-=d;
}
} void solve()
{
cin>>n>>m;
rep(i,1,m) cin>>x[i];
rep(i,1,m-1)
{
add(x[i],x[i+1],dist(x[i+1],x[i]));
add(x[i+1],x[i],dist(x[i],x[i+1]));
}
ll ans=1e18;
rep(i,1,n) cf[i]+=cf[i-1];
rep(i,1,n) ans=min(ans,cf[i]);
cout<<ans<<endl;
} int main()
{
IOS
// freopen("1.in", "r", stdin);
int t;
// cin>>t;
// while(t--)
solve();
return 0;
}

E题

#include <bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define fep(i,a,b) for(int i = (a); i >= (b); --i)
#define ls p<<1
#define rs p<<1|1
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ull unsigned long long
#define db double
#define endl '\n'
#define debug(a) cout<<#a<<"="<<a<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
#define x first
#define y second
#define pb push_back using namespace std;
const int N=4e5+10;
int cf[N],x[N],y[N]; void solve()
{
int n;cin>>n;
rep(i,1,n)
{
cin>>x[i]>>y[i];
if(x[i]>y[i]) swap(x[i],y[i]);
cf[x[i]]+=1;cf[y[i]+1]-=1;
}
rep(i,1,2*n) cf[i]+=cf[i-1];
rep(i,1,n)
{
if(cf[x[i]]!=cf[y[i]])
{
cout<<"Yes"<<endl;
return;
}
}
cout<<"No"<<endl;
}
signed main()
{
IOS
// freopen("1.in", "r", stdin);
// int _;
// cin>>_;
// while(_--)
solve();
return 0;
}

AtCoder Beginner Contest 338(A~E补题)的更多相关文章

  1. AtCoder Beginner Contest 188 F - +1-1x2 思维题

    题目描述 给你两个数 \(x\),\(y\) 可以对 \(x\) 进行 \(+1,-1\) 或 \(\times 2\) 的操作 问最少操作多少次后变为 \(y\) \(x,y \leq 10^{18 ...

  2. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  3. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  4. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  5. AtCoder Beginner Contest 223

    AtCoder Beginner Contest 223 A是纯纯的水题,就不说了 B - String Shifting 思路分析 我真的sb,一开始想了好久是不是和全排列有关,然后读了好几遍题目也 ...

  6. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  7. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

  8. AtCoder Beginner Contest 224

    AtCoder Beginner Contest 224 A - Tires 思路分析: 判断最后一个字符即可. 代码如下: #include <bits/stdc++.h> using ...

  9. KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解

    KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解 哦淦我已经菜到被ABC吊打了. A - Century 首先把当前年 ...

  10. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

随机推荐

  1. ​【心理学CPCI收录,AP独立出版】 2023年应用心理学与现代化教育国际学术会议(ICAPME 2023)

    ​[心理学CPCI收录,AP独立出版] 2023年应用心理学与现代化教育国际学术会议(ICAPME 2023) 大会官网:www.icapme.org 大会时间:2023年9月22-24日 大会地点: ...

  2. PCIe诞生20年来最大变革!引入光学传输

    PCI-SIG组织官方宣布,已经成立新的光学工作组(Optical Workgroup),研究为PCIe规范引入光学传输接口的可能性. PCIe标准是Intel 2001年提出的,2003年发布1.0 ...

  3. .NET Core开发实战(第14课:自定义配置数据源:低成本实现定制化配置方案)--学习笔记

    14 | 自定义配置数据源:低成本实现定制化配置方案 这一节讲解如何定义自己的数据源,来扩展配置框架 扩展步骤 1.实现 IConfigurationSource 2.实现 IConfiguratio ...

  4. Python-单引号、双引号和三引号的作用和区别

    (一).作用 1. 单引号:单引号内部为一串字符(str). 2. 双引号:双引号内部为一串字符,双引号内的字符串可以出现单引号(相当于双引号优先级更高),但不能嵌套双引号. 3. 三引号:用于换行输 ...

  5. Python-pymysql如何向SQL语句中传参

    方法一:不传递参数 ## 方式一.不传递参数 id = "01" name = "语文" sql = "select * from course wh ...

  6. Python 中Time 模块

    python的time内置模块是一个与时间相关的内置模块,很多人喜欢用time.time()获取当前时间的时间戳,利用程序前后两个时间戳的差值计算程序的运行时间,如下: 1.使用time.time() ...

  7. SATA 中ATA与AHCI的区别

    SATA中ATA和AHCI有什么区别?   1.ACHI是针对SATA2设计的,可以卡其NCQ功能,表面上没有速度的优势,但是因为算法不同,可以有效的保护硬盘.ATA 是硬件模拟IDE的一种方法.表面 ...

  8. python第五章pta习题总结

    四.编程部分 1.sorted函数: sorted(iterable, cmp=None, key=None, reverse=False) #iterable:可迭代的对象 #cmp:比较规则 #k ...

  9. Golang微服务框架go-kratos分析:框架架构分析

    一.kratos设计理念 这里主要讲解 kratos v2 的设计理念. kratos 框架制定接口规范,然后通过插件来实现具体需求,实现自由定制.可插拔的微服务框架. 我们既可以选择 kratos ...

  10. 使用go module导入本地包

    go module是Go1.11版本之后官方推出的版本管理工具,并且从Go1.13版本开始,go module将是Go语言默认的依赖管理工具. 前提 假设我们有learngo和mypackage两个 ...