目录

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. js设计模式(下)

    引用:(23条消息) <Javascript设计模式与开发实践>关于设计模式典型代码的整理(下):模板方法模式.享元模式.职责链模式.中介者模式.装饰模式.状态模式.适配器模式_QQsil ...

  2. 关于飞桨UIE等模型预测推理时间很久的问题分析以及解决,蒸馏剪枝部署问题解决

    1.关于飞桨UIE等模型预测推理时间很久的问题分析以及解决 1.1.原因分析 用uie做实体识别,Taskflow预测的时间与schema内的实体类别数量成正比,schema里面有多少个实体类别 实体 ...

  3. 高可用linux 服务器搭建

    最原始的服务部署,为单点部署,即直接把服务部署在一个服务器上.如果服务器出现故障,或者服务因为某个异常而挂掉,则服务就会发生中断.单点部署出现故障的概率最高. 后来,出现了网关,比如 nginx ko ...

  4. Kafka-如何重设消费者位移(重设OFFSET)

    1. 为什么要重设消费者组位移? 我们知道,Kafka 和传统的消息引擎在设计上是有很大区别的,其中一个比较显著的区别就是,Kafka 的消费者读取消息是可以重演的(replayable). 像 Ra ...

  5. 【若归】 【LGR-142-Div.4】洛谷入门赛 #13赛后反思

    比赛链接:[LGR-142-Div.4]洛谷入门赛 #13 rk288,比前几次差(可能是因为rated?) A 十年OI一场空,不开long long见祖宗 #include<bits/std ...

  6. NC52867 Highway

    题目链接 题目 题目描述 In ICPCCamp there were n towns conveniently numbered with \(1, 2, \dots, n\) connected ...

  7. 惠普CP1025 因转印离合器导致打印不全大片空白的问题

    问题症状 自检只打印出一部分, 后面大部分都是空白. 如果是碳盒缺粉, 应该是均匀地浅或者空白, 如果是成像鼓的问题, 应该是从上到下成条状的不均匀, 这样显示一节后空白的情况是没见过, 上网查有类似 ...

  8. STM32的串口通信UART/TTL

    常用的串口pin STM32的串口是基础通信方式, 每个型号都带多组串口, 一般都使用默认的组, 可以参考芯片的datasheet, 去看pinout and pin definitions, stm ...

  9. Qt三方库开发技术:QXlsx介绍、编译和使用

    若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...

  10. docker清理已停止的容器

    docker rm -v $(docker ps -aq -f status=exited) 可以将该命令写成shell脚本或者alias.-v参数表示同时清理数据卷