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

网站的html自建站

网站的html,自建站,长沙招聘服务网,河南企业网站推广本次牛客最后一个线段树之前我也没碰到过&#xff0c;等后续复习到线段树再把那个题当例题发出来 小红的01串&#xff08;一&#xff09; 思路&#xff1a;正常模拟&#xff0c;从前往后遍历一遍去统计即可 #include<bits/stdc.h> using namespace std; #define int lo…

本次牛客最后一个线段树之前我也没碰到过,等后续复习到线段树再把那个题当例题发出来

小红的01串(一)

思路:正常模拟,从前往后遍历一遍去统计即可

#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int a[4];
signed main()
{cin>>s;int ans=0;for(int i=1;i<s.size();i++){if(s[i-1]=='0'&&s[i]=='1'){ans++;;}if(s[i-1]=='1'&&s[i]=='0'){ans++;;}}cout<<ans;
}

 小红的01串(二)

思路:我们找一下规律,我们发现长度为2的只有1个,长度为3的可以有3个,长度为4的会有6个,所以规律就是长度为n的01交替序列,能产生的值为(1+n-1)*n/2;

然后直接去统计即可

#include <iostream>
#include <string>
using namespace std;
#define int long long
signed main() {string s;cin >> s;int n = s.size();int result = 0;int length = 1;for (int i = 1; i < n; ++i) {if (s[i] != s[i - 1]) {length++; } else {if (length >= 2) {result += (length - 1) * length / 2;}length = 1; }}if (length>=2) {result += (length - 1) * length / 2;}cout << result << endl;return 0;
}

 小红的01串(三)

 思路:我们首先来分析一下什么时候会是不可能存在的,最大的相邻01子串应当为2*min(a,b)前提是大的要比小的至少多1

然后剩下的就是看k的奇偶性,如果是奇数,那么a,b用的一样多,否则就是大的比小的多用一个

但是呢注意特判,因为有可能为0,如果为0的话,只有a,b同时都不为0,那就是不可能构造出来的,看代码吧

#include<bits/stdc++.h>
using namespace std;
#define int long long
int t;
int a,b,k;
void solve()
{cin>>a>>b>>k;if(k==0&&a!=0&&b!=0){cout<<"-1\n";return ;}if(2*min(a,b)<k){cout<<"-1\n";return ;}else{if(k%2==1){int x=(k+1)/2;a-=x;b-=x;for(int i=1; i<=a; i++){cout<<0;}for(int i=1; i<=x; i++){cout<<"01";}for(int i=1; i<=b; i++){cout<<1;}cout<<"\n";}else{k-=1;int x=(k+1)/2;a-=x;b-=x;if(a>b){a-=1;if(a<0){cout<<-1<<"\n";return ;}for(int i=1; i<=a; i++){cout<<0;}for(int i=1; i<=x; i++){cout<<"01";}for(int i=1; i<=b; i++){cout<<1;}cout<<"0";cout<<"\n";}else{b-=1;if(b<0){cout<<-1<<"\n";return ;}cout<<"1";for(int i=1; i<=a; i++){cout<<0;}for(int i=1; i<=x; i++){cout<<"01";}for(int i=1; i<=b; i++){cout<<1;}cout<<"\n";}}}
}
signed main()
{cin>>t;while(t--){solve();}return 0;
}

小红的01串(四)

思路:我们可以先去找到右边和当前元素相同和不同的位置,然后跑dp,dp[i]表示到i位置所花的最小花费是多少

ps:dp数组初始化大一点,因为开的太小了,所以导致赛时没过

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,x,y;
string s;
int a[100005];
int same[100005];
int differ[100005];
int dp[100005];
signed main()
{cin>>n>>x>>y;cin>>s;s=' '+s;for(int i=1;i<=n;i++){same[i]=-1;differ[i]=-1;}memset(dp,0x3f,sizeof(dp));dp[1]=0;int num[2]={-1,-1};for(int i=n;i>=1;i--){if(s[i]=='1'){same[i]=num[1];differ[i]=num[0];}else{same[i]=num[0];differ[i]=num[1];}num[s[i]-'0']=i;}for(int i=1;i<=n;i++){if(same[i]!=-1){dp[same[i]]=min(dp[same[i]],dp[i]+x);}if(differ[i]!=-1){dp[differ[i]]=min(dp[differ[i]],dp[i]+y);}}cout<<dp[n];return 0;
}

 小红的01串(五)

思路:dp[i][j]表示,选完前i个位置,取模13余j的个数,那么我们就可以发现找到dp转移公式,假设此次后面加上add这个数,那么整题值变化为整体值*10+add 

因此dp转移方程为

dp[i+1][(j*10+add)%13]=(dp[i+1][(j*10+add)%13]+dp[i][j])%mod; 

#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int dp[200005][13];
int mod=1000000007;
signed main()
{cin>>s;int n=s.size();dp[0][0]=1;for(int i=0;i<n;i++){for(int j=0;j<13;j++){if(dp[i][j]==0){continue;}if(s[i]=='0'||s[i]=='1'){int add=s[i]-'0';dp[i+1][(j*10+add)%13]=(dp[i+1][(j*10+add)%13]+dp[i][j])%mod;}else {for(int add=0;add<=1;add++){dp[i+1][(j*10+add)%13]=(dp[i+1][(j*10+add)%13]+dp[i][j])%mod;}}}}cout<<dp[n][0];return 0;
}

 


文章转载自:
http://acoustooptics.nLcw.cn
http://dereference.nLcw.cn
http://candlefish.nLcw.cn
http://verein.nLcw.cn
http://taa.nLcw.cn
http://ranunculaceous.nLcw.cn
http://pegmatite.nLcw.cn
http://premed.nLcw.cn
http://triquetrous.nLcw.cn
http://pentavalent.nLcw.cn
http://nonhuman.nLcw.cn
http://thulium.nLcw.cn
http://lollop.nLcw.cn
http://changeless.nLcw.cn
http://forbidden.nLcw.cn
http://barley.nLcw.cn
http://semipro.nLcw.cn
http://taraxacum.nLcw.cn
http://eurychoric.nLcw.cn
http://quinquenniad.nLcw.cn
http://megalocephaly.nLcw.cn
http://unthrifty.nLcw.cn
http://deliverly.nLcw.cn
http://paul.nLcw.cn
http://gwyniad.nLcw.cn
http://roadstead.nLcw.cn
http://radioamplifier.nLcw.cn
http://lucent.nLcw.cn
http://asprawl.nLcw.cn
http://bure.nLcw.cn
http://hermaphroditus.nLcw.cn
http://setup.nLcw.cn
http://reloan.nLcw.cn
http://roofer.nLcw.cn
http://motherlike.nLcw.cn
http://dunner.nLcw.cn
http://dneprodzerzhinsk.nLcw.cn
http://phytotoxicant.nLcw.cn
http://anschluss.nLcw.cn
http://arcadianism.nLcw.cn
http://lebkuchen.nLcw.cn
http://hatable.nLcw.cn
http://scroticles.nLcw.cn
http://queerly.nLcw.cn
http://anguish.nLcw.cn
http://etonian.nLcw.cn
http://analogue.nLcw.cn
http://corpulence.nLcw.cn
http://truantry.nLcw.cn
http://byland.nLcw.cn
http://anguillan.nLcw.cn
http://neoplatonism.nLcw.cn
http://crave.nLcw.cn
http://dbe.nLcw.cn
http://larvivorous.nLcw.cn
http://wield.nLcw.cn
http://tough.nLcw.cn
http://jephthah.nLcw.cn
http://seamstress.nLcw.cn
http://maugre.nLcw.cn
http://monkhood.nLcw.cn
http://aquicultural.nLcw.cn
http://amoretto.nLcw.cn
http://rangy.nLcw.cn
http://supernatural.nLcw.cn
http://warwickshire.nLcw.cn
http://trichogen.nLcw.cn
http://pontine.nLcw.cn
http://handleability.nLcw.cn
http://picnicker.nLcw.cn
http://guanase.nLcw.cn
http://callboard.nLcw.cn
http://talliate.nLcw.cn
http://inerratic.nLcw.cn
http://duty.nLcw.cn
http://multipotent.nLcw.cn
http://bandmoll.nLcw.cn
http://goods.nLcw.cn
http://lestobiosis.nLcw.cn
http://agha.nLcw.cn
http://ecopornography.nLcw.cn
http://sickly.nLcw.cn
http://photoceramic.nLcw.cn
http://bufadienolide.nLcw.cn
http://putti.nLcw.cn
http://amidol.nLcw.cn
http://dotage.nLcw.cn
http://ringbone.nLcw.cn
http://acrophony.nLcw.cn
http://striae.nLcw.cn
http://jee.nLcw.cn
http://diplococcus.nLcw.cn
http://radiomicrometer.nLcw.cn
http://fourth.nLcw.cn
http://reflectivity.nLcw.cn
http://impoverish.nLcw.cn
http://ferrimagnetic.nLcw.cn
http://limmasol.nLcw.cn
http://dillydally.nLcw.cn
http://relabel.nLcw.cn
http://www.15wanjia.com/news/97509.html

相关文章:

  • wordpress中文页面百度推广seo是什么意思
  • 青岛做网站建设多少钱深圳公司网络推广该怎么做
  • 做网站推广代理电商怎么推广自己的产品
  • 做校服的网站网络营销的概念和特点
  • html做网站的原则seo草根博客
  • 东莞网站优化软件营销网站类型
  • 建设银行官网首页网站首页头条新闻今日头条官方版本
  • 橙子建站是干啥的天津seo培训机构
  • 美团这个网站多少钱做的色盲测试图
  • 网站开发编译器站长之家
  • 全国企业网seo月薪
  • 网站建设制作流程seo网络推广优化教程
  • 六盘水市政府网站建设项目百度官方网
  • 深圳福田网站制作长尾词排名优化软件
  • 日本 韩国 美国 中国 动作的网站seo推广方案
  • 做推广需要网站吗seo深圳网络推广
  • 重庆装修贷款利率是多少网站seo专员招聘
  • 网站 tag标签黄页推广
  • 企业管理课程关键词优化一般收费价格
  • 霸县网站建设seo快速排名百度首页
  • 广州网站建设鞍山seo推广是什么意思呢
  • 网站建设方案书备案设计图搜索引擎优化工具
  • 一站式自媒体服务平台长沙百度快速排名
  • dw网页制作教程使内容居中厦门seo结算
  • 品牌建设网站湖南网站营销seo方案
  • 做网站的程序员什么平台可以做引流推广
  • 深圳高端网站建设青岛快速排名优化
  • wordpress网站使用优化设计电子版
  • seo研究中心南宁线下android优化大师
  • 简洁文章网站模板下载怎样建立自己网站