倒计时39天

牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)

cpp 复制代码
//m
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int inf=0x3f3f3f3f;
#define int long long
int a[N],b[N];
void solve()
{
    int n,cn=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]%36]++;
    }
    for(int i=1;i<=n;i++)
    {
        int r=a[i];
        int c=1;
        while(r)
        {
            c*=10;
            r/=10;
        }
        for(int j=0;j<=35;j++)
        {
            if(((j*(c%36))%36+a[i]%36)%36==0)
            {
                cn+=b[j]-(a[i]%36==j);
            }
        }
    }
    cout<<cn;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

牛客竞赛_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)

cpp 复制代码
//d
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int a[N];
void solve()
{
	int n,cn=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cn+=a[i];
    }
    if(n==1)
    {
        cout<<1<<endl;
        return ;
    }
    int cnt=0;
    for(int i=1;i<=cn/n;i++)
    {
        if(cn%i==0)cnt++;
    }
    cout<<cnt;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
//e
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
map<int,int>mp;
void solve()
{
	int n,k,x,cn=0,cnt=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        cn+=x;
        if(cn%k==0||mp[cn%k])
        {
            cnt++;
            mp.clear();
            cn=0;
        }
        else mp[cn%k]=1;
    }
    cout<<cnt;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
//g
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
char s[510][510];
int sum[510][510];
void solve()
{
	int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>s[i][j];
            if(s[i][j]=='*')
            {
                sum[i][j]=sum[i][j-1]+1;
            }
            else sum[i][j]=sum[i][j-1];
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            for(int k=1;k<=n;k++)
            {
                if(s[i+k][j+k]!='*'||s[i+k][j-k]!='*'||s[i][j]!='*')break;
                if(sum[i+k][j+k]-sum[i+k][j-k-1]==2*k+1)ans++;
            }
        }
    }
    cout<<ans;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
相关推荐
风落青芜4 小时前
C++入门:类和对象(三)
开发语言·数据结构·c++·算法
iou_q4 小时前
为什么C++中在构造函数中使用初始化列表更快?
c++
wuminyu5 小时前
OpenJDK学习笔记:Native线程如何回调Java
java·linux·c语言·jvm·c++
杜 硕5 小时前
从零开始的C++生活——第十五讲
开发语言·数据结构·c++·生活
纪念 2296 小时前
C++ 算法模板与错题 模拟(一)
android·c++·算法
随流寻影6 小时前
利用 C++ 实现二叉搜索树的增删查
开发语言·c++
学逆向的7 小时前
C++多态 汇编分析
开发语言·汇编·c++·网络安全
ShineWinsu8 小时前
对于Qt:QSound的解析
c++·qt·面试·音频·笔试·客户端·qsound
derek19978 小时前
软考软件设计师:白盒覆盖哪条最弱、McCabe 复杂度怎么数、单元测试最能发现什么错
c语言·c++·计算机网络·软件工程·学习方法
沫璃染墨9 小时前
从零入门计算机网络系列(三十一):Linux I/O 多路复用详解——select 工作原理与底层机制
linux·运维·服务器·网络·c++·网络协议·信息与通信