日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Count Subrectangles CodeForces - 1323B(思维)

發布時間:2023/12/15 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Count Subrectangles CodeForces - 1323B(思维) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

You are given an array a of length n and array b of length m both consisting of only integers 0 and 1. Consider a matrix c of size n×m formed by following rule: ci,j=ai?bj (i.e. ai multiplied by bj). It’s easy to see that c consists of only zeroes and ones too.

How many subrectangles of size (area) k consisting only of ones are there in c?

A subrectangle is an intersection of a consecutive (subsequent) segment of rows and a consecutive (subsequent) segment of columns. I.e. consider four integers x1,x2,y1,y2 (1≤x1≤x2≤n, 1≤y1≤y2≤m) a subrectangle c[x1…x2][y1…y2] is an intersection of the rows x1,x1+1,x1+2,…,x2 and the columns y1,y1+1,y1+2,…,y2.

The size (area) of a subrectangle is the total number of cells in it.

Input
The first line contains three integers n, m and k (1≤n,m≤40000,1≤k≤n?m), length of array a, length of array b and required size of subrectangles.

The second line contains n integers a1,a2,…,an (0≤ai≤1), elements of a.

The third line contains m integers b1,b2,…,bm (0≤bi≤1), elements of b.

Output
Output single integer — the number of subrectangles of c with size (area) k consisting only of ones.

Examples
Input
3 3 2
1 0 1
1 1 1
Output
4
Input
3 5 4
1 1 1
1 1 1 1 1
Output
14
Note
In first example matrix c is:

There are 4 subrectangles of size 2 consisting of only ones in it:

In second example matrix c is:

思路:思路感覺挺好想的,但是有可能容易超時。對于連續的1個數相同的情況,我們可以合并考慮,因為他們的情況都是一樣的。因此,我們可以分別計算出a序列,連續的1的個數有多少種情況,并記錄每一種情況的個數。同理求出b序列的。然后我們分別遍歷a,b序列的這些情況,求出符合條件的就可以了。
代碼如下:

#include<bits/stdc++.h> #define ll long long using namespace std;const int maxx=4e4+100; map<int,int> p1,p2; int a[maxx]; int b[maxx]; int n,m,k;inline void dfs(int c[],int &j,int limit) {if(j>limit) return ;if(c[j]==0) return ;dfs(c,j+=1,limit); } inline void fcs() {int j;for(int i=1;i<=n;){if(a[i]==1){j=i;dfs(a,j,n);p1[j-i]++;i=j;}else i++;}for(int i=1;i<=m;){if(b[i]==1){j=i;dfs(b,j,m);p2[j-i]++;i=j;}else i++;} } inline void solve() {int len1,len2,num1,num2,_min,_max;ll sum=0;for(map<int,int> ::iterator it1=p1.begin();it1!=p1.end();it1++){len1=it1->first;num1=it1->second;for(map<int,int> ::iterator it2=p2.begin();it2!=p2.end();it2++){len2=it2->first;num2=it2->second;_min=min(len1,len2);_max=max(len1,len2);for(int i=1;i<=min(_min,k);i++){if(k%i==0&&k/i<=_max) sum+=((_max-k/i+1)*(_min-i+1))*num1*num2;}}}cout<<sum<<endl; } int main() {scanf("%d%d%d",&n,&m,&k);for(int i=1;i<=n;i++) cin>>a[i];for(int i=1;i<=m;i++) cin>>b[i];p1.clear();p2.clear();fcs();solve();return 0; }

努力加油a啊,(o)/~

總結

以上是生活随笔為你收集整理的Count Subrectangles CodeForces - 1323B(思维)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日韩中文字幕视频 | 中文字幕11页中文字幕11页 | 国产精品自拍网站 | 亚洲美女偷拍 | 女生扒开腿让男生操 | 午夜精品福利在线观看 | mm131美女大尺度私密照尤果 | 国产女主播在线 | 亚洲AV成人无码电影在线观看 | 五月天超碰| 黄网址在线观看 | 灌篮高手全国大赛电影 | 一区二区三区四区在线观看视频 | 日韩欧美电影一区二区三区 | 国产1区在线观看 | 成年免费视频黄网站在线观看 | 深夜精品| 久热这里| 人成免费 | 色先锋影院| 800av在线播放 | 国产一区二区三区视频网站 | 国产欧美日韩在线观看 | www国产视频| 亚洲一区二区三区久久久成人动漫 | 三级黄色视屏 | 性v天堂 | 无码人妻一区二区三区av | 国产婷婷色一区二区三区 | 西方裸体在线观看 | 午夜免费网| 亚洲第一在线播放 | 葵司有码中文字幕二三区 | aaa在线视频 | 国产毛片久久久久久 | 特黄三级 | av网站不卡| 做a爰小视频| 97精品人妻一区二区三区香蕉 | 亚洲精品久久久蜜桃 | www四虎com| 九九久久网 | 扒开美女内裤狂揉下部 | 性插动态视频 | 国产精品一区二区在线播放 | 欧美日韩成人在线视频 | 亚洲一区自拍偷拍 | 欧美一级黄色录像 | 日本理论片午伦夜理片在线观看 | 亚洲av成人无码一二三在线观看 | 狠狠人妻久久久久久综合 | 午夜嘿嘿嘿 | 操视频网站 | 国产99免费| 国产九九精品 | 国产毛片电影 | 一本色道久久综合精品婷婷 | 在线a| 驯服少爷漫画免费观看下拉式漫画 | 色性av| 打屁股视频网站 | 成年网站在线播放 | 风流老熟女一区二区三区 | 丰满岳乱妇一区二区 | 娇小萝被两个黑人用半米长 | 在线观看视频你懂得 | 午夜小视频在线播放 | 污网站免费看 | 天天综合久久 | 综合精品一区 | 精品视频成人 | 日韩一区二区三区四区 | 日韩免费黄色片 | 欧洲日韩一区二区三区 | 亚洲精品久久夜色撩人男男小说 | 亚洲精品成人a | 免费欧美视频 | 在线不卡日本 | 欧美精品第1页 | 国产精品12p | 精品无码av一区二区三区 | 一区二区三区免费观看 | sm乳奴虐乳调教bdsm | 久久久精品国产sm调教网站 | 成人自拍网站 | 日韩人妻精品中文字幕 | youjizz日本人 | 欧美有码在线观看 | 四虎影视永久 | 91色多多| 国产三级在线免费观看 | 午夜国产 | 欧洲精品一区 | 人妻少妇被猛烈进入中文字幕 | 熟妇女人妻丰满少妇中文字幕 | 深夜福利免费在线观看 | 日韩avav| 日韩一区二区影院 | 国产精品一区在线看 |