倒计时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;
}
相关推荐
清朝牢弟1 小时前
Ubuntu系统VScode实现opencv(c++)图像像素类型转换和归一化
c++·opencv·ubuntu
黑色的山岗在沉睡1 小时前
P1948 [USACO08JAN] Telephone Lines S
数据结构·c++·算法·图论
玖剹2 小时前
Linux文件操作:从C接口到系统调用
linux·服务器·c语言·c++·笔记·ubuntu
ikkkkkkkl4 小时前
LeetCode:15.三数之和&&18.四数之和
c++·算法·leetcode
pusue_the_sun4 小时前
从零开始搞定类与对象(中)
开发语言·c++·学习
屁股割了还要学4 小时前
【数据结构入门】链表
c语言·开发语言·数据结构·c++·学习·算法·链表
君鼎5 小时前
Effective C++ 条款19: 设计class犹如设计type
c++
源代码•宸5 小时前
C++高频知识点(十四)
开发语言·c++·经验分享·raii
易ლ拉罐6 小时前
【C++】封装,this指针
c++
独好紫罗兰7 小时前
C++信息学奥赛一本通-第一部分-基础一-第一章
c++·算法