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

手机自适应网站建设制作网页模板

手机自适应网站建设,制作网页模板,浙江住房和建设网站,给县里做网站https://vjudge.net/contest/581947 A - Ultra-QuickSort 题意 每次给n个无序的数,互不重复,问最少需要多少次必要的交换操作使n个数有序。 思路 看一眼想到逆序数,然后验证了逆序数的个数符合样例,但想了一个3 2 1的话实际上…

https://vjudge.net/contest/581947

A - Ultra-QuickSort

题意

每次给n个无序的数,互不重复,问最少需要多少次必要的交换操作使n个数有序。

思路

看一眼想到逆序数,然后验证了逆序数的个数符合样例,但想了一个3 2 1的话实际上只需要交换一次,但题意说的是必要交换次数也不一样是最优的交换次数,那样就太难了。
于是就简化问题求一个序列逆序数的个数,就用归并了上课讲过,可以在归并拆分返回的时候进行求逆序对,求逆序对两种,一种求每个数的右边比它小的数的个数,一种求每个数左边比它大的个数,我用第二种做的,归并返回的时候,两个数组都是有序的可以求右边的数组中每个元素,对于左边一共有几个比他大的,代码能力还行,wa了一次因为数组开的int 归并一次就写对了,我感觉我又行了哈哈哈。

#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;const int maxn=500005;
long long a[maxn],box[maxn];
long long ans;
void mergesort(int left,int right)
{if(left>=right) return;int mid=(left+right)/2;mergesort(left,mid);mergesort(mid+1,right);int j=left;for(int i=mid+1;i<=right;i++){while(a[j]<a[i]&&j<=mid){j++;}	ans=ans+mid-j+1;}	int i=left;j=mid+1;int t=1;while(i<=mid&&j<=right){if(a[i]<=a[j])box[t++]=a[i++];elsebox[t++]=a[j++];}while(i<=mid)box[t++]=a[i++];while(j<=right)box[t++]=a[j++];t=1;for(int i=left;i<=right;i++)a[i]=box[t++];
}
int main()
{int n;while(scanf("%d",&n)&&n!=0){memset(a,0,sizeof(a));for(int i=1;i<=n;i++)scanf("%lld",&a[i]);ans=0;mergesort(1,n);
//		for(int i=1;i<=n;i++)
//			printf("%d ",a[i]);
//		printf("\n");		printf("%lld\n",ans);}	return 0;
}

B - Hanoi Tower Troubles Again!

题意

给n个柱子,这个人要从第一根柱子到第n个柱子挨个往上面放球,球编号从1开始递增,要求两个相邻球编号和为完全平方数。

思路

简单模拟题

#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;int box[55];
int main()
{int T;scanf("%d",&T);while(T--){int n;scanf("%d",&n);memset(box,0,sizeof(box));int i=1;while(1){int flag=0;for(int j=1; j<=n; j++){if(box[j]==0){box[j]=i++;flag=1;break;}else{int k=(int)sqrt(box[j]+i);if(k*k==(box[j]+i)){box[j]=i++;flag=1;break;}}}if(flag==0) break;}printf("%d\n",i-1);}
}

C - Fibonacci Again

思路:模拟题

#include<bits/stdc++.h> 
using namespace std;const int MAXN=1000005;
int f[MAXN]; 
int main()
{f[0]=7;f[1]=11;for(int i=2;i<=1000000;i++)	f[i]=f[i-1]%3+f[i-2]%3;int t;while(scanf("%d",&t)!=EOF){if(f[t]%3==0)printf("yes\n");		elseprintf("no\n");}return 0;
}

E - Fire Net

题意

给n*n(n<=4)的格子,格子上可能有墙,或者为空地,空地可以建设碉堡,碉堡可以上下左右射击,射不穿墙,问最多可以建设多少碉堡?

思路

DFS模拟简单题
一共最多16个格子嘛,我就是从上往下,从左往右,挨个尝试每个位置,然后对于每个位置能不能安装,只需要扫描它的上方和左方是否有碉堡就可以啦,注意一下边界就好。

#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;int m[10][10];
int n;
int ans;
void dfs(int start,int cnt)
{if(start>n*n){ans=max(ans,cnt);
//		if(cnt>=4)
//		{
//			for(int i=1; i<=n; i++,printf("\n"))
//				for(int j=1; j<=n; j++)
//					printf("%d ",m[i][j]);
//			printf("\n");
//		}return;}int row=(start-1)/n+1;int col=(start-1)%n+1;for(int i=start; i<=n*n; i++){
//		取if(m[row][col]!=1){int flag=1;for(int j=col-1; j>=1&&m[row][j]!=1; j--)if(m[row][j]==2){flag=0;break;}for(int j=row-1; j>=1&&m[j][col]!=1; j--)if(m[j][col]==2){flag=0;break;}if(flag){m[row][col]=2;dfs(i+1,cnt+1);m[row][col]=0;}}
//		不取dfs(i+1,cnt);}return;
}
int main()
{while(scanf("%d",&n)&&n!=0){ans=0;getchar();for(int i=1; i<=n; i++){for(int j=1; j<=n; j++){char c;scanf("%c",&c);if(c=='.') m[i][j]=0;else m[i][j]=1;}getchar();}for(int i=1; i<=n*n; i++){dfs(i,0);}printf("%d\n",ans);}
}
/*
4
.X..
....
XX..
....
*/

G - Maximum Subarray Sum

题意

最大连续子序列和

思路

简单题,注意开long long和可能超int

#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=2e5+5;
int a[MAXN];
int main()
{int n;scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&a[i]);long long maxx=0;long long ans=a[1];for(int i=1;i<=n;i++){maxx=maxx+a[i];ans=max(maxx,ans);if(maxx<0) maxx=0;}printf("%lld",ans);
}

J - Beat the Spread!

#include<cstring>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>int main()
{int T;scanf("%d",&T);while(T--){int a,b;scanf("%d%d",&a,&b);if((a+b)%2){printf("impossible\n");continue;}int maxx=(a+b)/2;int minn=a-maxx;if(maxx<0||minn<0){printf("impossible\n");continue;}printf("%d %d\n",maxx,minn);}
}

文章转载自:
http://chickpea.ddfp.cn
http://brewhouse.ddfp.cn
http://postpone.ddfp.cn
http://billingsgate.ddfp.cn
http://citrine.ddfp.cn
http://ambisextrous.ddfp.cn
http://cutpurse.ddfp.cn
http://champak.ddfp.cn
http://equipollence.ddfp.cn
http://sewer.ddfp.cn
http://absent.ddfp.cn
http://undefended.ddfp.cn
http://glaciated.ddfp.cn
http://zenana.ddfp.cn
http://concelebrate.ddfp.cn
http://additory.ddfp.cn
http://truss.ddfp.cn
http://evangeline.ddfp.cn
http://cleanout.ddfp.cn
http://huanghe.ddfp.cn
http://arbalist.ddfp.cn
http://vaal.ddfp.cn
http://epazote.ddfp.cn
http://hypopraxia.ddfp.cn
http://egomaniacally.ddfp.cn
http://peashooter.ddfp.cn
http://distinctness.ddfp.cn
http://funiculate.ddfp.cn
http://landwaiter.ddfp.cn
http://quaveringly.ddfp.cn
http://reflexed.ddfp.cn
http://eurailpass.ddfp.cn
http://pbs.ddfp.cn
http://maieutic.ddfp.cn
http://billingual.ddfp.cn
http://temperately.ddfp.cn
http://circumferential.ddfp.cn
http://swore.ddfp.cn
http://sphygmography.ddfp.cn
http://practised.ddfp.cn
http://tzar.ddfp.cn
http://turps.ddfp.cn
http://malvina.ddfp.cn
http://thick.ddfp.cn
http://montana.ddfp.cn
http://reborn.ddfp.cn
http://psilanthropy.ddfp.cn
http://bea.ddfp.cn
http://ligula.ddfp.cn
http://fractionalism.ddfp.cn
http://semiliterate.ddfp.cn
http://weariful.ddfp.cn
http://curr.ddfp.cn
http://indebt.ddfp.cn
http://explanatory.ddfp.cn
http://mandolin.ddfp.cn
http://incipience.ddfp.cn
http://honeymouthed.ddfp.cn
http://whang.ddfp.cn
http://ineradicable.ddfp.cn
http://yrast.ddfp.cn
http://quivive.ddfp.cn
http://conventicle.ddfp.cn
http://clearstory.ddfp.cn
http://timebargain.ddfp.cn
http://plebeian.ddfp.cn
http://neuropteron.ddfp.cn
http://disregardful.ddfp.cn
http://utopism.ddfp.cn
http://tauromachy.ddfp.cn
http://vigilance.ddfp.cn
http://ichnography.ddfp.cn
http://hepatitis.ddfp.cn
http://neuromast.ddfp.cn
http://picornavirus.ddfp.cn
http://coly.ddfp.cn
http://luncheonette.ddfp.cn
http://homocercality.ddfp.cn
http://houseleek.ddfp.cn
http://clotho.ddfp.cn
http://obviation.ddfp.cn
http://gripe.ddfp.cn
http://kislev.ddfp.cn
http://vividly.ddfp.cn
http://humbling.ddfp.cn
http://sulfhydrate.ddfp.cn
http://folksay.ddfp.cn
http://elemi.ddfp.cn
http://genius.ddfp.cn
http://rikisha.ddfp.cn
http://disseminative.ddfp.cn
http://homme.ddfp.cn
http://marinera.ddfp.cn
http://floruit.ddfp.cn
http://syntechnic.ddfp.cn
http://glass.ddfp.cn
http://headsman.ddfp.cn
http://cervix.ddfp.cn
http://desaturate.ddfp.cn
http://turnkey.ddfp.cn
http://www.hrbkazy.com/news/91630.html

相关文章:

  • 建设官方网站多少百度推广客户端下载安装
  • 深圳建网站的专业公司seo搜索引擎优化方法
  • 什么网站做优化最好网站建设推广
  • 梧州市网站建设店铺推广怎么做
  • 江苏网站建设效果好电商seo搜索优化
  • 重庆网站建设公司 今日小说百度搜索风云榜
  • 婚恋网站建设成本佛山优化网站关键词
  • 杭州网站建设工作室百度在线咨询
  • 网站建设计入什么会计科目百度导航下载2022最新版官网
  • wordpress安装免费HTTPS网络优化工程师工资
  • 下载长沙app南京seo排名优化公司
  • 广州做网站公司排名深圳高端网站制作公司
  • 怎样开网店详细步骤上海抖音seo公司
  • 棕色网站软件测试培训班多少钱
  • 怎么做劳务公司网站近期国内新闻热点事件
  • 昆明网站制作推荐百度我的订单查询
  • 网站建设专业品牌雅虎日本新闻
  • 免费做公司手机网站数据分析方法
  • 建设工程的在建设部网站58同城如何发广告
  • 南宁品牌网站建设网络营销现状分析
  • 泰州网站制作方案定制常见的网络推广方法有哪些
  • 邯郸网站设计招聘开发网站建设
  • 网站被k了怎么做杭州网络排名优化
  • 做酱菜网站推广普通话手抄报简单
  • 网站做缓存口碑营销案例2022
  • python编程软件手机版网络优化工具app手机版
  • 大连百度做网站推广电话好的建站网站
  • 品牌网鞋有哪些牌子天津抖音seo
  • 简单的电影网站模板免费的域名和网站
  • 网站设计制作服务热线百度网页链接