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)的更多相关文章

  1. 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 ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  10. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. CAT监控指标

    CAT监控指标 CAT 是基于 Java 开发的实时应用监控平台.官方文档:https://github.com/dianping/cat CAT提供以下几种报表:Transaction报表 一段代码 ...

  2. 终端读取iOS项目所有设置参数(版本号、应用名等)

    在某些场景下(比如自动化打包等),我们需要从终端来读取到iOS项目的数据,首先先上代码 xcodebuild -showBuildSettings -target 项目target 但有时候我们需要将 ...

  3. 蚁群算法及 TSP 问题上的应用

    群智能(Swarm intelligence) 自然界动物群,称之为群. 群的特征: 相互作用的相邻个体的集合 个体的行为简单,既有竞争又有协作 智能化的集体行为(1+1>2): 个体间不仅能够 ...

  4. 基于 Cloudflare Workers 和 cloudflare-docker-proxy 搭建镜像加速服务

    本文主要介绍了如何基于 Cloudflare Workers 和 cloudflare-docker-proxy 搭建 dockerhub.gcr.quay 等镜像加速服务. 最近,受限于各种情况,部 ...

  5. python_8 拆包、内置函数和高阶函数

    一.查缺补漏 1. \t 子表符,用于对其二.拆包 1. 拆包:顾名思义就是将可迭代的对象如元组,列表,字符串,集合,字典,拆分出相对应的元素 2. 形式:拆包一般分两种方式,一种是以变量的方式来接收 ...

  6. 基于防火墙的SSLVPN

    SCVPN即SSLVPN 拓补图 记得打开策略! 设置外接口(一些管理方式要打开) 设置SSL 地址池(如没要求设iP,随意设) 建立SSL VPN 出接口,地址池要选对 创建一个本地用户(账号A 密 ...

  7. java中的即时编译(JIT)简介

    Java发展这么多年一直长青,很大一部分得益于开发人员长期对其坚持不懈的优化:写得更少,跑得更快!JIT就是其中一项十分重要的优化. JIT全程Java Intime Compiler,即Java即时 ...

  8. 全网最适合入门的面向对象编程教程:08 类和对象的Python实现-@property装饰器:把方法包装成属性

    全网最适合入门的面向对象编程教程:08 类和对象的 Python 实现-@property 装饰器:把方法包装成属性 摘要: 本文主要对@property 装饰器的基本定义.使用场景和使用方法进行了介 ...

  9. 异构数据源数据同步 → 从源码分析 DataX 敏感信息的加解密

    开心一刻 出门扔垃圾,看到一大爷摔地上了 过去问大爷:我账户余额 0.8,能扶你起来不 大爷往旁边挪了挪 跟我说到:孩子,快,你也躺下,这个来钱快! 我没理大爷,径直去扔了垃圾 然后飞速的躺在了大爷旁 ...

  10. docker卸载分享

    一.准备工作: 1.杀死docker有关的容器: docker kill $(docker ps -a -q) 2.删除所有docker容器: docker rm $(docker ps -a -q) ...