Codeforces Round 905 (Div. 3)

A. Morning

题意:操作:显示,向前走都为一次操作;目标:显示这四个数

思路:0->10,然后依次作差就行

#include <bits/stdc++.h>
using namespace std;
void solve(){
char a[4];
int mi=100,sum=4,b[4];
for(int i=0;i<4;i++){
cin>>a[i];
b[i]=a[i]-'0';
if(b[i]==0) b[i]=10;
}
sum+=b[0]-1;
for(int i=1;i<4;i++){
sum+=abs(b[i]-b[i-1]);
}
cout<<sum<<"\n";
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

B. Chemistry

题意:操作:删除一个数;目标:让该字符串变成一个回文字符串

!!!操作之后可以随意更改顺序看题不要只看一半不然会被卡

思路:一共26个字母统计出现次数,只要是偶数就可以当成回文串

#include <bits/stdc++.h>
using namespace std;
int num[27];
void solve(){
memset(num,0,sizeof(num));
int n,k;
cin>>n>>k;
int res=0;
for(int i=0;i<n;i++){
char a;
cin>>a;
int x=a-'a';
num[x]++;
}
for(int i=0;i<26;i++){
if(num[i]%2!=0) res++;
}
if(res-k>1) cout<<"NO"<<"\n";
else{
cout<<"YES"<<"\n";
}
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

C. Raspberries

题意:操作:给其中一个数+1;目标:使所有数的乘积可以被k整除

思路:k=2,3,4,5,其中3个质数为一类,4为一类

1.只要数列中有一个数的因子为k那么就能整除,不能的话就算他的mod最大的

2.如果有其中一个数+1刚好为4的倍数(特殊情况)/其中有一个数为2的倍数不为4的倍数得1,或者有两个数为2的倍数则可以直接得0,最多只需加两次,即将两个奇数分别+1然后变为偶数可直接除4.

#include <iostream>
using namespace std;
const int MAX=1e5+10;
#define int long long
int arr[MAX]; void solve() {
int n, k;
cin >> n >> k;
if (k == 4) {
int res = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
bool x=false;
for(int i=0;i<n;i++){
if((arr[i]+1)%4==0){
x=true;
}while(arr[i]%2==0){
res++;
arr[i]/=2;
if(res==2){
cout<<"0\n";
return ;
}
}
}
if(x||res==1) cout<<"1\n";
else cout<<"2\n";
} else {
int ma = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}for(int i=0;i<n;i++){
if (arr[i] % k == 0) {
cout<<"0\n";
return ;
}
ma = max(ma, arr[i] % k);
}
cout << k - ma << endl;
}
} signed main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}

D. In Love

题意:操作:增加或者减少一条边;结果:是否存在不重合的边

思路:只需要判断有边的右端点小于他的左端点

#include <bits/stdc++.h>
using namespace std;
map<int,int> l;
map<int,int> r;
void solve(){
char a;
int b,c;
cin>>a>>b>>c;
if(a=='+'){
l[b]++;
r[c]++;
}else{
auto x=l.find(b);
x->second--;
if(x->second==0) l.erase(x); auto h=r.find(c);
h->second--;
if(h->second==0) r.erase(h);
}if(l.empty()||l.rbegin()->first<=r.begin()->first)
{
cout<<"No\n";
}else cout<<"Yes\n"; }
int main()
{
int t;
cin>>t;
while(t--){ solve(); }
return 0;
}

E. Look Back

题意:操作ai=ai*2;结果:整个数组为递增数组

思路:首先排除暴力,必爆long long,所以可以拿一个变量来记录前一个乘了几个2

#include <iostream>
using namespace std;
#define int long long
void solve(){
int n,res=0,a=0,b=0,num=0;
cin>>n>>a;
for(int i=1;i<n;i++) {
cin >> b;
if (b > a) {
int a2 = a;
while (a2 <= b && a2 != 0) {
a2 <<= 1;
num--;
}
num++;
num = num > 0 ? num : 0;
res += num;
a = b;
continue;
} else if (a == b) {
res += num;
continue;
} else {
int b2 = b;
while (b2 < a) {
num++;
b2*=2;
}
res += num;
a = b;
}
}
cout<<res<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

F. You Are So Beautiful

题意:有多少个子数组让数组中只有一个子序列和他相等

坑货,没注意是子序列,直接给我卡爆了

注意:子序列是不连续的,子数组是连续的

思路:只需要保证子数组的左端点是第一次出现在数组中,右端点是最后一次出现在数组中

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+10;
int a[MAX];
void solve(){
int n;
cin>>n;
map<int,int> mp;
for(int i=0;i<n;i++){
cin>>a[i];
mp[a[i]]=i;
}
long long int res=0,pre=0;
set<int> num;
for(int i=0;i<n;i++){
if(num.count(a[i])==0){
pre++;
num.insert(a[i]);
}if(mp[a[i]]==i){
res+=pre;
}
}
cout<<res<<endl;
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

G1. Dances (Easy version)

题意:操作:删除a[i],b[i];要求:a[i]<b[i]

思路:排序,然后删除,双指针

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+10;
int a[MAX],b[MAX];
void solve(){
int n,m;
cin>>n>>m;
a[0]=1;
for(int i=1;i<n;i++){
cin>>a[i];
}for(int i=0;i<n;i++){
cin>>b[i];
}
sort(a,a+n);
sort(b,b+n); int ia=0,res=0;
for(int ib=0;ib<n;ib++){
if(a[ia]>=b[ib]){
res++;
}else{
ia++;
}
}
cout<<res<<"\n";
}
int main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}

Codeforces Round 905 (Div. 3)的更多相关文章

  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. jmeter对请求响应结果进行整段内容提取方法

    通过正则表达式提取器,将上一个请求(A请求)响应数据中的整段内容提取,传给下一个需要该提取数据的请求(B请求). 1. 请求接口响应结果 2. 添加正则表达式提取器 设置变量名为"tt&qu ...

  2. 10、Mybatis之缓存

    10.1.环境搭建 10.1.1.创建新module 创建名为mybatis_cache的新module,过程参考5.1节 10.1.2.创建Mapper接口和映射文件 package org.rai ...

  3. 在原生APP中集成Unity容器

    随着技术的发展,越来越多的APP期望拥有3D,AR的能力.要达到这个目标可以选择使用原生开发,也可以使用Unity成熟的3D开发技术链,通过嵌入的方式将Unity容器嵌入到APP中.这里介绍的是通过嵌 ...

  4. 带你读论文丨Fuzzing漏洞挖掘详细总结 GreyOne

    本文分享自华为云社区<[论文阅读] (03) 清华张超老师 - Fuzzing漏洞挖掘详细总结 GreyOne>,作者: eastmount. 一.传统的漏洞挖掘方法 演讲题目: 数据流敏 ...

  5. 一文了解Gin对Cookie的支持

    1. 引言 本文将从Web应用程序处理请求时需要用户信息,同时HTTP又是无状态协议这个矛盾点出发.从该问题出发,简单描述了解决该问题的Token 机制,进而引出Cookie的实现方案. 基于此我们将 ...

  6. Unity 游戏开发、03 基础篇 | C#初级编程

    C#初级编程 https://learn.u3d.cn/tutorial/beginner-gameplay-scripting 8 Update 和 FixedUpdate Update(不是按固定 ...

  7. skynet的timer似乎有问题

    skynet.timeout 传进去 number 范围内的数值但是会溢出, 调查发现 skynet.timeout 调用的是 c 的方法: c.intcommand("TIMEOUT&qu ...

  8. Skynet:Debug Console的扩展

    起因 最近上线服务器遇到了一些问题,上个月CPU暴涨的问题,那个经查验是死循环导致endless loop了. 这周又遇到了mem占用达到96%的问题,在debug console里调用了gc之后,跌 ...

  9. lvm格式化挂载分区

    1.从物理磁盘创建lvm分区 物理磁盘 /dev/sdb 20G 2.使用fdisk工具创建lvm分区 3.修改默认的分区类型 4.查看新建的分区 5.创建物理卷pv 6.创建逻辑卷组vg,并查看详情 ...

  10. Redis系列之——高级用法

    文章目录 一 慢查询 1.1 生命周期 1.2 两个配置 1.2.1 slowlog-max-len 1.2.2 slowlog-max-len 1.2.3 配置方法 1.3 三个命令 1.4 经验 ...