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. 从浅入深了解.NET Core MVC 2.x全面教程【第二章】

    二.Logging 1.诊断中间件 命名空间:Microsoft.AspNetCore.Diagnostics 报告信息并处理异常 2.诊断中间件 UseDeveloperExceptionPage: ...

  2. Java日志系列:Log4j使用和原理分析

    目录 一.简介 二.使用 三.日志级别 四.组件说明 Loggers Appenders Layouts 五.配置 加载初始化配置 配置文件加载 查看日志记录器的详细信息 六.Layout的格式 七. ...

  3. 【pytorch】目标检测:新手也能彻底搞懂的YOLOv5详解

    YOLOv5是Glenn Jocher等人研发,它是Ultralytics公司的开源项目.YOLOv5根据参数量分为了n.s.m.l.x五种类型,其参数量依次上升,当然了其效果也是越来越好.从2020 ...

  4. Blazor前后端框架Known-V1.2.14

    V1.2.14 Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行. Gitee: https://gitee.com/known/Known Git ...

  5. springboot3框架搭建

    Spring Boot 3.0.0已经发布一段时间了,越来越多的公司考虑将技术框架升级到最新版本,JDK也相应要求JDK17以上.对应Spring Boot 2.x的版本,建议先升级到Spring B ...

  6. HiAI Foundation助力端侧音视频AI能力,高性能低功耗释放云侧成本

    过去三年是端侧AI高速发展的几年,华为在2020年预言了端侧AI的发展潮流,2021年通过提供端云协同的方式使我们的HiAI Foundation应用性更进一个台阶,2022年提供视频超分端到端的解决 ...

  7. Node.js vs. Spring Boot:Hello World 性能对决,谁更快一点?

    前言: Spring Boot 在 Java 生态中备受欢迎,它是一款基于 Java 构建的轻量级服务端框架,主要用于 Web 服务.Spring Boot 的应用使得创建各类基于 Spring 的企 ...

  8. 对某个接口进行限流 以 Aop 注解的形式绑定接口 用redis实现

    简单的针对某个接口进行限流,如果需要整体限流的话还是建议在网关上面或者服务器上面动手Controller: @LimitRequest(count = 1,time = 60 * 1000 * 2) ...

  9. 使用Eclipse生成CHM帮助文档(图解)

    使用Eclipse生成CHM帮助文档(图解) 博客分类: System Operate javadoc生成chm文档java生成api帮助文档api帮助文档生成工具 Eclipse JavaDoc和j ...

  10. idea修改默认maven配置

    idea修改默认maven配置 方法一 (不推荐) 打开project.default.xml文件,在其中加入如下几行配置. 代码如下 保存修改之后新建一个maven项目查看效果 方法二 新增Proj ...