Codeforces Round 964 (Div. 4)
Codeforces Round 964 (Div. 4)
A送分
B
大意:两个人两张牌 随机翻 求a翻出来的牌比b大的可能
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#define ep emplace_back
using namespace std;
void solve() {
int ans = 0;
int a1, b1, a2, b2;
cin >> a1 >> a2 >> b1 >> b2;
int cnt1 = 0, cnt2 = 0;
if (a1 > b1)
cnt1++;
else if (a1 < b1)
cnt2++;
if (a2 > b2)
cnt1++;
else if (a2 < b2)
cnt2++;
if (cnt1 > cnt2)
ans += 2;
cnt1 = cnt2 = 0;
if (a1 > b2)
cnt1++;
else if (a1 < b2)
cnt2++;
if (a2 > b1)
cnt1++;
else if (a2 < b1)
cnt2++;
if (cnt1 > cnt2)
ans += 2;
cout << ans << "\n";
}
int main() {
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
C
题目大意:有些区间被阻断 找连续的区间 判断最长的长度能否大于S
思路:保证l,r是不相交的 扫一遍所有的区间就好了 跑两个指针 pos1=0,pos2=l
#include<iostream>
using namespace std;
void solve(){
int n,s,m;
scanf("%d%d%d",&n,&s,&m);
bool ok=0;
int pos=0;
for(int i = 0; i < n; ++i){
int l,r;
scanf("%d%d",&l,&r);
int k = l-pos;
if( k>=s )
ok=1;
pos=r;
}
if(m-pos>=s) ok=1;
if(ok) cout<<"YES";
else cout<<"NO";
cout<<"\n";
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
D
题目大意:给定字串字符s t s某些字符可以修改 能否通过修改s st t是s子序列
思路:两个指针扫一遍,? 或者能匹配就让第二个指针往前跑,最后判断第二个指针跑到尾了
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
using namespace std;
void solve(){
string s,t;
cin>>s>>t;
int j=0;
for(int i = 0; i < s.size(); ++i){
if(s[i] == '?' ){
if(j < t.size()){
s[i] = t[j];
++j;
}
else {
s[i] = 'a';
}
}
else if( s[i] == t[j] and j<t.size()){
++j;
}
}
if(j == t.size()) cout<<"YES"<<"\n"<<s;
else cout<<"NO";
cout<<"\n";
}
int main(){
int _;
cin>>_;
while(_ --){
solve();
}
}
E:
题意:写下L,L+1,...R-1,R个数字,操作他,让一个数乘以三,另一个除以三。直到所有为0 求最小的操作次数
思路:先让L为0 ans 加上操作次数 观察到[3,8] opt=2,[9,26]opt=3 只需要计算区间长度乘以区间对应的opt次数就可
#include <iostream>
#include <cmath>
#include <cstdio>
#define lld long long
using namespace std;
int f(int x){
int ans=0;
while(x!=0){
x/=3;
ans++;
}
return ans;
}
void solve(){
int L,R;
cin>>L>>R;
int K = f(L);
int M = f(R);
lld ans=0;
int a[50],b[50];
for(int i=0;i<=32;++i){
a[i] = pow(3,i);
b[i] = pow(3,i+1)-1;
}
ans+=2*f(L);
int pos=L+1;
for(int i=f(L+1) ; i <= M; ++i){
//printf("ans=%d ",ans);
int pos2 = b[i-1];
if(pos2>R){
pos2=R;
//printf("pos=%d pos2=%d \n",pos,pos2);
ans+=(pos2-pos+1)*i;
break;
}
else {
//printf("pos=%d pos2=%d \n",pos,pos2);
ans+=(pos2-pos+1)*i;
pos = a[i];
}
}
cout<<ans<<"\n";
}
int main(){
int T;
cin>>T;
while(T--){
solve();
}
}
// 2 3 4 5 6 7 8 9 10 11 12
// 1 2 2 2 2 2 2 3 3 3 3
// 14+12 = 22
F:
大意:
思路:
Codeforces Round 964 (Div. 4)的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- Mysql慢sql优化
Mysql慢sql优化 index1.MySQL的执行过程2.索引的定义3.MySQL执行计划explain or desc4.索引使用/创建规则5.弊端6.设计规范7.SQL建议 1. MySQL ...
- 微服务引入swagger生成接口的json导入到yapi配置方法 数据管理 开启url导入
微服务引入swagger生成接口的json导入到yapi配置方法 数据管理 开启url导入 yapi安装参考window10 yapi安装 swagger配置 及 Error: getaddrinfo ...
- 揭秘In-Context Learning(ICL):大型语言模型如何通过上下文学习实现少样本高效推理[示例设计、ICL机制详解]
揭秘In-Context Learning(ICL):大型语言模型如何通过上下文学习实现少样本高效推理[示例设计.ICL机制详解] 自GPT-3首次提出了In-Context Learning(ICL ...
- 这几个必备的vscode插件,你安装了几个
作为一名前端开发者,vscode想必大家应该都接触过,就像大多数 IDE 一样,VSCode 也有一个扩展和主题市场,包含了数以千计质量不同的插件. 作为一名熟练掌握各种前端开发工具安装和卸载的大师兄 ...
- 配置h5py、netCDF4库的方法:Anaconda环境
本文介绍基于Anaconda环境,下载并安装Python中h5py与netCDF4这两个模块的方法. 在Python语言中,h5py与netCDF4这两个模块是与遥感图像处理.地学分析等GIS ...
- 三层交换机vlan间路由
sw1: [Huawei]vlan batch 10 20 [Huawei]int e0/0/1 [Huawei-Ethernet0/0/1]port link-type access [Huawei ...
- 脚本与数据的解耦 + Page Object模型
标签(空格分隔): 脚本与数据的解耦 + Page Object模型 测试脚本和数据的解耦 你现在已经掌握了一些基本的 GUI 自动化测试用例的实现方法,是不是正摩拳擦掌准备批量开发 GUI 自动化脚 ...
- 痞子衡嵌入式:浅聊恩智浦i.MXRT官方SDK里关于串行Flash相关的驱动与例程资源(上篇)
大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是恩智浦i.MXRT官方SDK里关于串行Flash相关的驱动与例程资源. 经常有同事以及 i.MXRT 客户咨询痞子衡,咱们恩智浦官方 S ...
- Nginx常用操作
Nginx Nginx的最重要的几个使用场景 静态资源服务,通过本地文件提供服务 反向代理服务,延伸出包括缓存,负载均衡等 API服务,OpenResty 相关概念 简单请求和非简单请求 请求方法是H ...
- 类、事件与对象---Dad&Mom简单练习
目的: 模拟一个家庭日常发生的场景:妈妈做好饭,说:"开饭了!",这是爸爸听到了妈妈的喊话就立马动身开始饭吃.而儿子此时正在打游戏,于是他就说:"等我打完这把游戏再吃!& ...