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为还需要的蜡烛数, ...
随机推荐
- Spring AOP 中@Pointcut的用法(多个Pointcut)
Spring AOP 中@Pointcut的用法(多个Pointcut) /** swagger切面,分开来写 **/ @Aspect @Component public class ApiOpera ...
- vue项目中一些常用的插件
@riophae/vue-treeselect:带选择的树组件 https://vue-treeselect.js.org/ ele-calendar:日历组件 https://www.npmjs.c ...
- Linux中的环境变量PS1,打造你的专属终端
文章目录 介绍 PS1的格式 设置字体样式 举例 小建议 进阶 介绍 好看的终端是怎么做的呢?通过PS1这个环境变量! PS1的格式 PS1='[\u@\h \w]\$ ' 样式: 解释: [是普通字 ...
- Windows无法访问vsftpd
在搭建vsftpd的时候注意放行相应的服务,注意,是服务,不是端口!! 如果你简单的--add-port放行20和21端口,那么恭喜你,就是访问不了. 正确的方法是--add-service=ftp, ...
- Java(screw)生成数据库表结构
数据库支持 MySQL MariaDB TIDB Oracle SqlServer PostgreSQL Cache DB(2016) 文档生成支持 html word markdown 方式一:代码 ...
- java WT -- JSON WEB TOKEN 加密/校验工具类
依赖项 <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</art ...
- QAnything AI开源的企业级本地知识库问答解决方案,致力于支持任意格式文件或数据库的问答
QAnything AI简介 QAnything ai是一个本地知识库问答系统,旨在支持多种文件格式和数据库,允许离线安装和使用.您可以简单地删除任何格式的任何本地存储文件,并获得准确.快速和可靠的答 ...
- [oeasy]python0111_字型码_字符字型编码_点阵字库_ascii演化
编码进化 回忆上次内容 上次回顾了 早期的英文字符点阵 最小的 3*5 通用的 5*7 点阵字库逐渐规范化 添加图片注释,不超过 140 字(可选) 这些点阵字符的字型 究竟是 ...
- Known框架实战演练——进销存系统需求
概述 该项目是一个开源.简易.轻量级的进销存管理系统,作为Known框架的实战演练项目. 项目代码:JxcLite 开源地址: https://gitee.com/known/JxcLite 功能模块 ...
- ASP.NET Core WebAPI 使用CreatedAtRoute通知消费者
一.目的 我想告诉消费者我的api关于新创建的对象的位置 二.方法说明 public virtual Microsoft.AspNetCore.Mvc.CreatedAtRouteResult Cre ...