倒计时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;
}
相关推荐
D_evil__20 分钟前
【Effective Modern C++】第三章 转向现代C++:7. 在创建对象时注意区分()和{}
c++
Bruce_kaizy41 分钟前
c++ dfs搜索算法——剪枝
c++·深度优先·剪枝
CSDN_RTKLIB1 小时前
【std::string】find函数
c++·stl
十五年专注C++开发1 小时前
浅谈CPU中的SIMD
c++·cpu·代码优化·simd
Yu_Lijing1 小时前
基于C++的《Head First设计模式》笔记——状态模式
c++·笔记·设计模式
顶点多余2 小时前
静态链接 vs 动态链接,静态库 vs 动态库
linux·c++·算法
AI视觉网奇2 小时前
ue5 开发 web socket server 实战2026
c++·学习·ue5
王老师青少年编程2 小时前
2024年3月GESP真题及题解(C++八级): 接竹竿
c++·题解·真题·gesp·csp·八级·接竹竿
偷星星的贼112 小时前
C++中的访问者模式实战
开发语言·c++·算法
雾岛听蓝3 小时前
红黑树深度解析:设计原理与实现逻辑
c++