关于队里面最菜的在博客打卡第四十五天这件事

传送门:https://codeforces.com/contest/1323/problem/B

这是一道模拟题,需要找出来非零段的长度统计再合并之后再算一下数据就行。

题目:

 ac代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
using namespace std;
typedef long long int LL ;
typedef pair<LL,LL> PLL ;
const int N = 4e4 + 10;
LL a[N] , b[N];


int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    LL n , m , k ;
    cin >> n >> m >> k ;
    map<LL,LL> mplen , mplenb;
    int temp = 0 ;
    for(int i = 1; i <= n ; i ++)
    {
        cin >> a[i];
        if(a[i] == 1)temp ++ ;
        else if(a[i] == 0)
        {
            if(temp)mplen[temp] ++ ;
            temp = 0 ;
        }
        
        if(i == n && temp)mplen[temp] ++ ;
    }
    map <PLL,int> mpsta;//大小.
    temp = 0 ;
    for(int i = 1; i <= m ; i ++)
    {
        cin >> b[i];
        if(b[i] == 1)temp ++ ;
        else if(b[i] == 0)
        {
            if(temp)mplenb[temp] ++ ;
            temp = 0 ;
        }
        if(i == m && temp )mplenb[temp] ++ ;
    }
    for(auto ita : mplen)
        for(auto itb : mplenb)
        {
            mpsta[{max(ita.first,itb.first), min(ita.first,itb.first)}] += ita.second * itb.second;
        }
    vector<pair<PLL,int>> v;
    for(auto it : mpsta)
    {
        v.push_back(it);
    }
    LL ans = 0 ;
    LL tempA,tempB;
    vector<PLL> yue;
    for(int i = 1; i <= k/i ; i ++)
    {
        if(k % i != 0)continue;
        else yue.push_back({i,k/i});
    }
    for(int i = 0 ; i < v.size() ; i ++)
    {
        LL A = v[i].first.first , B = v[i].first.second;
        if(A * B <k )continue;
        LL tempans = 0 ;
        for(int j = 0; j < yue.size(); j ++)
        {
            tempA = yue[j].first , tempB = yue[j].second;

            if(A >= tempA  && B >= tempB)
            tempans += (A - tempA + 1) * (B - tempB + 1) * v[i].second;
            
            if(tempA != tempB && A >= tempB && B >= tempA)
            tempans += (A - tempB + 1) * (B - tempA + 1) * v[i].second;
        }
        ans += tempans;
    }
    cout << ans <<endl;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值