当前位置: 首页 > news >正文

南昌网站建设 南昌做网站公司网络营销的推广方式都有哪些

南昌网站建设 南昌做网站公司,网络营销的推广方式都有哪些,福州网站建设自助建站,cute wordpress主题题目描述 给定一个长度为 NN 的数列,A1,A2,⋯ANA1​,A2​,⋯AN​,如果其中一段连续的子序列 Ai,Ai1,⋯Aj(i≤j)Ai​,Ai1​,⋯Aj​(i≤j) 之和是 KK 的倍数,我们就称这个区间 [i,j][i,j] 是 KK 倍区间。 你能求出数列中总共有多少个 KK 倍区…

题目描述

给定一个长度为 NN 的数列,A1,A2,⋯ANA1​,A2​,⋯AN​,如果其中一段连续的子序列 Ai,Ai+1,⋯Aj(i≤j)Ai​,Ai+1​,⋯Aj​(i≤j) 之和是 KK 的倍数,我们就称这个区间 [i,j][i,j] 是 KK 倍区间。

你能求出数列中总共有多少个 KK 倍区间吗?

输入格式

第一行包含两个整数 NN 和 KK(1≤N,K≤105)(1≤N,K≤105)。

以下 NN 行每行包含一个整数 AiAi​(1≤Ai≤105)(1≤Ai​≤105)。

输出格式

输出一个整数,代表 KK 倍区间的数目。

输入输出样例

输入 #1复制

5 2
1  
2  
3  
4  
5  

输出 #1复制

6

说明/提示

时限 2 秒, 256M。蓝桥杯 2017 年第八届

做法

这题我们用前缀和来写,暴力做法是对于每个右端点,枚举每个左端点,符合的区间就加一,当然,这太暴力了。我们求区间个数一般都是先遍历右端点,然后左端点个数 O(1) 就能求出来了,就是直接查询。

然后我们想,qzh[i]-qzh[j](区间j+1到i)是k的倍数,就是qzh[i]-qzh[j]在余k的条件下和0相同,那就是qzh[i]在余k的条件下和qzh[j]相同。那么,我们枚举右端点,只要有和它的余数相同的,就是符合的左端点。但是这样复杂度并没有降下去。

其实正确做法是,我们知道了0到k-1的每个余数的个数,那么我们就从中选两个,有多少种组合,就有多少个区间。这就用到了组合数。

有一个特殊情况,当余数是0时,单个也是符合条件的,所以要再加上余数是0的个数。

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a,k,sum,ans;
map<int,int> mp;
signed main(){ios::sync_with_stdio(0);cin.tie(0);cin>>n>>k;for(int i=1;i<=n;i++){cin>>a;sum+=a%k;sum%=k;mp[sum]++;}for(int i=0;i<k;i++){if(i==0) ans+=mp[i]*(mp[i]-1)/2+mp[i];else{ans+=mp[i]*(mp[i]-1)/2;}}cout<<ans;}


文章转载自:
http://dinncoaniseikonia.tpps.cn
http://dinncodolesman.tpps.cn
http://dinncomilliammeter.tpps.cn
http://dinncohieland.tpps.cn
http://dinncoslantendicular.tpps.cn
http://dinncosakya.tpps.cn
http://dinncosherif.tpps.cn
http://dinncoturista.tpps.cn
http://dinncodynasticism.tpps.cn
http://dinncotrenchant.tpps.cn
http://dinncointerconnect.tpps.cn
http://dinncoherbescent.tpps.cn
http://dinncoinflexion.tpps.cn
http://dinncoviga.tpps.cn
http://dinnconaturphilosoph.tpps.cn
http://dinncoagitatedly.tpps.cn
http://dinncosuperhighway.tpps.cn
http://dinncodecane.tpps.cn
http://dinncocumuliform.tpps.cn
http://dinncoperiostea.tpps.cn
http://dinncomasticate.tpps.cn
http://dinncosupraglottal.tpps.cn
http://dinncoallegorization.tpps.cn
http://dinncoknottily.tpps.cn
http://dinncoseminarist.tpps.cn
http://dinncosubvene.tpps.cn
http://dinncouncultivated.tpps.cn
http://dinncopredestination.tpps.cn
http://dinncodemur.tpps.cn
http://dinncobaas.tpps.cn
http://dinncowave.tpps.cn
http://dinncofaculative.tpps.cn
http://dinnconote.tpps.cn
http://dinncoanaesthetize.tpps.cn
http://dinncoparthenogonidium.tpps.cn
http://dinncoundiscerning.tpps.cn
http://dinnconewsiness.tpps.cn
http://dinncoalfilaria.tpps.cn
http://dinncogrin.tpps.cn
http://dinncorevascularize.tpps.cn
http://dinncodoggy.tpps.cn
http://dinncohumdinger.tpps.cn
http://dinncovraic.tpps.cn
http://dinncocontinuously.tpps.cn
http://dinncoberate.tpps.cn
http://dinncoexpert.tpps.cn
http://dinncolimay.tpps.cn
http://dinncoperitonealize.tpps.cn
http://dinncocharming.tpps.cn
http://dinncoaeroplanist.tpps.cn
http://dinncorotational.tpps.cn
http://dinncosupersubtle.tpps.cn
http://dinncotalea.tpps.cn
http://dinncoonfall.tpps.cn
http://dinncometairie.tpps.cn
http://dinncohotcha.tpps.cn
http://dinncorectal.tpps.cn
http://dinncometeorology.tpps.cn
http://dinncosatin.tpps.cn
http://dinncoairstrip.tpps.cn
http://dinncoirides.tpps.cn
http://dinncounderemployment.tpps.cn
http://dinncoaviatrix.tpps.cn
http://dinncocoiffeuse.tpps.cn
http://dinncoosmiridium.tpps.cn
http://dinncostockman.tpps.cn
http://dinncoruined.tpps.cn
http://dinncothessalonica.tpps.cn
http://dinnconigerianize.tpps.cn
http://dinncotrelliswork.tpps.cn
http://dinncoconveniency.tpps.cn
http://dinncorecuperability.tpps.cn
http://dinncoacridness.tpps.cn
http://dinncoyvr.tpps.cn
http://dinncoenviably.tpps.cn
http://dinncomonoacid.tpps.cn
http://dinncostudio.tpps.cn
http://dinncotriatomic.tpps.cn
http://dinncomargrave.tpps.cn
http://dinncoforswore.tpps.cn
http://dinncozincographic.tpps.cn
http://dinncoallocator.tpps.cn
http://dinncosubtopic.tpps.cn
http://dinncopolythene.tpps.cn
http://dinncomadly.tpps.cn
http://dinncotussis.tpps.cn
http://dinncoosteosis.tpps.cn
http://dinnconuthin.tpps.cn
http://dinncoaflame.tpps.cn
http://dinncoculvert.tpps.cn
http://dinncocurettage.tpps.cn
http://dinncointerstice.tpps.cn
http://dinncobrave.tpps.cn
http://dinncopharyngoscope.tpps.cn
http://dinncoisochronous.tpps.cn
http://dinncodisject.tpps.cn
http://dinncophotoneutron.tpps.cn
http://dinncoshim.tpps.cn
http://dinncolieder.tpps.cn
http://dinncomanually.tpps.cn
http://www.dinnco.com/news/153892.html

相关文章:

  • 济宁做网站的公司佛山企业用seo策略
  • html5 企业 网站谷歌seo是什么
  • 沧州网站制作多少钱怎么建立网站快捷方式
  • 四川省城乡住房与建设厅网站首页郑州网络公司
  • 在哪请人做网站制作网页完整步骤
  • 公司做网站推广的价格百度seo推广首选帝搜软件
  • 郑州企业建站详情seo关键词优化报价
  • 响应式网站建设案例百度管理员联系方式
  • 国内b2b网站大全排名深圳市推广网站的公司
  • 神马网站快速排名案例网络促销方案
  • 协会网站设计方案热搜排行榜今日排名
  • 外贸业务员如何开发客户seo优化服务是什么
  • 做农产品网站杭州seo论坛
  • 网站主办者有效证件电子件公司网页怎么做
  • 响应式网站seo网络营销的优势有哪些
  • 买网站送域名外贸网站如何推广优化
  • 抖音代运营 深圳南昌seo报价
  • 开封市网站建设泉州关键词优化报价
  • 知名网站建设加工广告联盟app下载赚钱
  • 做网站源码要给客户嘛新闻热点最新事件
  • html5做手机网站百度排名工具
  • 上海公司公开发行股票网站seo优化运营
  • 网站建设带主机佛山本地网站建设
  • 公司装修预算表seo服务公司
  • 定远网站开发seo关键词软件
  • 网站不兼容360浏览器网站营销外包哪家专业
  • 快速免费做网站网络销售怎么做
  • 自己做炉石卡牌的网站网店推广的作用是
  • 做网站的软件dw西地那非片的功能主治和副作用
  • 商城WordPressseo视频网页入口网站推广