A. Soccer

------------------------题解---------------

给你开始比分和结束比分问你中间两队比分有没有相等过有可能就是YES不可能就是NO

结束时两队比分肯定>=各自队伍开始时比分,我们只需要让开始时大的先到达结束比分,再让开始时落后的比分到达结束时比分,只需要在心中模拟这个过程

最后就能写出一个O1的if 判断

点击查看代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll a[N],b[N],c[N];
bool vis[N];
pair<ll,ll> p[N];
int main()
{
ll t;
cin>>t;
while(t--)
{
ll a,b,c,d;
cin>>a>>b>>c>>d;
if(a<b&&c<d) cout<<"YES"<<'\n';
else if(b<a&&d<c) cout<<"YES"<<'\n';
else cout<<"NO"<<'\n'; }
}

B

-------------------------------题解-----------------------------

按照过程模拟就行,稍微优化一下把+1的过程编程x一下加到能被y整除的过程,只要每进行一次操作后x能被y整除就一直除以y

点击查看代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll a[N],b[N],c[N];
bool vis[N];
pair<ll,ll> p[N];
int main()
{
ll t;
cin>>t;
while(t--)
{
ll x,y,k;
cin>>x>>y>>k; /* if(x<y)
{
if(k>=y-(x%y)) cout<<1+(k-(y-(x%y)))%y<<'\n';
else cout<<x+k<<'\n';
}
else if(y-(x%y)>k) cout<<x+k<<'\n'; else
{*/
ll num=x;
num++;
k--;
int jud=0;
while(num!=1)
{ jud++;
// cout<<num<<" "<<k<<" "<<y<<endl;
if(num%y==0)
{
while(num%y==0) num=num/y;
//cout<<num<<endl;
}
else if(k>=y-(num%y))
{
k-=(y-(num%y));
num+=(y-(num%y));
while(num%y==0) num=num/y;
//
// cout<<1<<endl;
}
else break;
if(k==0) break;
}
// cout<<num<<" "<<k<<endl;
ll w=num+k;
if(num==1) w=1+(k%(y-1));
// while(w%y==0) w=w/y;
cout<<w<<'\n'; }
}

C Boring Day

-----------------------------题解----------------------------

O(n)的线性模拟一下就好 按照以下决策

设置一个sum

sum+=a[i]只要sum到了l和r的范围就立马不拿了 cnt++

超了也不拿了 cnt不变

按照这个决策模拟便是正确答案

点击查看代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll a[N],b[N],c[N];
bool vis[N];
pair<ll,ll> p[N];
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,l,r;
cin>>n>>l>>r;
for(ll i=1;i<=n;i++) cin>>a[i];
// sort(a+1,a+1+n);
ll sum=0;
ll cnt=0;
ll l1=1;
for(ll i=1;i<=n;i++)
{
sum+=a[i];
if(sum>=l&&sum<=r) cnt++,sum=0,l1=i+1;
else if(sum>r)
{
while(sum>r)
{
sum-=a[l1];
l1++; }
if(sum<=r&&sum>=l) cnt++,l1=i+1,sum=0; } }
cout<<cnt<<'\n'; }
}

D. Beauty of the mountains

------------------------------题解----------------------------

先把所有0与1位置上的和加起来称为sum 这需要遍历nm中 每一个kk方块中0 与 1的绝对值差 然后再看这些绝对值差(假设为有两个绝对值差分别为x,y) 则要看k1x+k2y是否能==sum

我们需要知道一个事情,只要这个sum与n个绝对值差求gcd 最后求出来的结果==1 那便是符合根据这个判断即可,,,这里这个题的关键就结束了,为了避免超时,我们还需要注意用二位前缀和优化一下记录各个区块内0和1的差值PS:比赛二位前缀和这里挂了不然出了.

点击查看代码
#include<bits/stdc++.h>
using namespace std;
const int N=510;
int a[N][N];
char b[N][N];
int n,m,k;
int c[N][N];
void solve()
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(b[i][j]=='1') c[i][j]=1;
else c[i][j]= -1;
c[i][j]+=c[i][j-1]+c[i-1][j]-c[i-1][j-1];
}
} }
int main()
{
int t;
cin>>t;
while(t--)
{ cin>>n>>m>>k;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++) cin>>a[i][j];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++) cin>>b[i][j];
}
int s1=0,s0=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(b[i][j]=='1') s1+=a[i][j];
else s0+=a[i][j]; }
} int s3=abs(s1-s0);
int jud=1;
if(s3==0)
{
cout<<"YES"<<'\n';
continue;
}
//cout<<s3<<endl;
int e=-2; solve();
/* for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<c[i][j]<<" "; }
cout<<endl;
}*/
if(jud!=0){ for(int i=1;i<=n-k+1;i++)
{
for(int j=1;j<=m-k+1;j++)
{
int num=(c[i+k-1][j+k-1]-c[i-1][j+k-1]-c[i+k-1][j-1]+c[i-1][j-1]);
if(e==-2&&num!=0) e=num;
else if(num!=0) e=__gcd(e,abs(num));
//cout<<num<<endl;
// cout<<e<<endl;
}
}
}
if(s3%e==0||e==0) cout<<"YES"<<'\n';
else cout<<"NO"<<'\n'; }
}
/*
1
3 4 3
46 49 50 1
19 30 23 12
30 25 1 46
1000
0100
0010
*/

Codeforces Round 955 (Div. 2, with prizes from NEAR!) codeforces div2 955的更多相关文章

  1. Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索

    Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...

  2. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

  3. Codeforces Round #427 (Div. 2) Problem A Key races (Codeforces 835 A)

    Two boys decided to compete in text typing on the site "Key races". During the competition ...

  4. Codeforces Round #425 (Div. 2) Problem C Strange Radiation (Codeforces 832C) - 二分答案 - 数论

    n people are standing on a coordinate axis in points with positive integer coordinates strictly less ...

  5. Codeforces Round #258 (Div. 2)[ABCD]

    Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...

  6. Codeforces Round #500 (Div. 2) [based on EJOI]

    Codeforces Round #500 (Div. 2) [based on EJOI] https://codeforces.com/contest/1013 A #include<bit ...

  7. Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!]

    Codeforces Round #518 (Div. 2) [Thanks, Mail.Ru!] https://codeforces.com/contest/1068 A #include< ...

  8. Codeforces Round #261 (Div. 2)[ABCDE]

    Codeforces Round #261 (Div. 2)[ABCDE] ACM 题目地址:Codeforces Round #261 (Div. 2) A - Pashmak and Garden ...

  9. Codeforces Round #547 (Div. 3) 题解

    Codeforces Round #547 (Div. 3) 题目链接:https://codeforces.com/contest/1141 A,B咕咕了... C. Polycarp Restor ...

  10. Codeforces Round #546 (Div. 2) 题解

    Codeforces Round #546 (Div. 2) 题目链接:https://codeforces.com/contest/1136 A. Nastya Is Reading a Book ...

随机推荐

  1. Dinky实时计算平台

    前言:Apache Flink 作为新一代的实时计算框架已经被应用到各个行业与领域,其岂存在着应用的痛点比如 FlinkSQL 在线IDE.作业提交不友好.作业无监控报警等.很大程度上说,FlinkS ...

  2. 模型评测-书生浦语大模型实战营学习笔记7&大语言模型12

    大语言模型学习-12.模型评测 书生浦语大模型实战营学习笔记7 视频教程特别像广告,所以这篇博客参考了很多其他内容给大家参考,主要是下面几个页面: https://zhuanlan.zhihu.com ...

  3. 如何获取Github Token

    登录我们的github账号,点击头像后选择Settings 进入界面之后下拉到左侧菜单的最后,选择Developer settings 进入界面后,选择Personal access tokens-- ...

  4. nginx中目录浏览配置

    root方式配置:(会自动加目录名) #开放本地目录-root server { listen 81; server_name localhost 127.0.0.1 0.0.0.0; charset ...

  5. 荒岛野人Savage

    题目描述 样例 3 1 3 4 2 7 3 3 2 1 6 分析 首先,我们先设4个变量,初始坐标 \(d[i]\),每年步数 \(p[i]\),寿命 \(l[i]\),根据题目很容易得到一个不等式 ...

  6. JDK源码阅读-------自学笔记(二十二)(java.util.ArrayList自定义晋级,ArrayList实战详解)

    简介(Introduction)   上篇文章主要介绍了ArrayList自行模仿建立的方式,那么,其实这个类不是一次性就那么完美的,现在做一个一步步变成那样完整的ArrayList的版本升级测试. ...

  7. 促双碳|AIRIOT智慧能源管理解决方案

      随着"双碳"政策和落地的推进,各行业企业围绕实现碳达峰和碳中和为目标,逐步开展智能化能源管理工作,通过能源数据统计.分析.核算.监测.能耗设备管理.碳资产管理等多种手段,对能源 ...

  8. 京东二面:Sychronized的锁升级过程是怎样的

    引言 Java作为主流的面向对象编程语言,提供了丰富的并发工具来帮助开发者解决多线程环境下的数据一致性问题.其中,内置的关键字"Synchronized"扮演了至关重要的角色,它能 ...

  9. linux各个目录详细说明

    在linux中一切皆文件,每个目录均有自己特定的作用,下面进行详细说明. 目录 说明 / 处于linux系统树形结构的最顶端,它是linux文件系统的入口,所有的目录.文件.设备都在 / 之下 /bi ...

  10. c++ 记一次把qrencode源码生成动态库的尝试

    在网上搜二维码库:qrencode,源码下载:https://github.com/fukuchi/libqrencode 我的是windows环境,IDE是vs2022. 建立一个动态库的空工程. ...