(cf·div3#839)https://codeforces.com/contest/1772

Source

https://codeforces.com/contest/1772/problem/A
题意:a+b的题,只是给的是字符串罢了
思路:第一反应下面的做法,但无奈人发烧发糊涂了,懒小菲阳写错了。最后为了尽快解决还是把它当成字符串。

#include<bits/stdc++.h>
using namespace std;
#define int long long
int b[200005];
int s[]={
    
      1,2,4,7,11,16,22,29,37,46};
signed main()
{
    
      
	int tt;
	for(cin>>tt;tt--;)
	{
    
      
		int x,y;
		char c;
		scanf("%lld%c%lld",&x,&c,&y);
		printf("%lld\n",x+y);
	}
}

哈!懒小菲羊说,“不喜欢跟着题意来写”。
于是第二题:
https://codeforces.com/contest/1772/problem/B
题意:
a b
c d
问abcd是不是漂亮的,漂亮是指:同一行,左边的比右边的数小;同一列,上面的比下面的小。

思路:最小的和最大的在对角线位置,且a,b,c,d互不相等即可。

实际上我好笨,只能用最蠢的方法做。
懒小菲羊说,她不喜欢写长代码。

#include<bits/stdc++.h>
using namespace std;
#define int long long
//int b[200005];
signed main()
{
    
      
	int tt;
	for(cin>>tt;tt--;)
	{
    
      
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int v[4];
		v[0]=a,v[1]=b,v[2]=c,v[3]=d;
		sort(v,v+4);
		set<int>s;
		s.insert(a);s.insert(b);s.insert(c);s.insert(d);
		if(s.size()!=4)
		{
    
      
			puts("NO");continue;
		}
		if(v[0]==a)
		{
    
      
			if(v[3]==d)puts("YES");
			else puts("NO");
		}
		else if(v[0]==b)
		{
    
      
			if(v[3]==c)puts("YES");
			else puts("NO");
		}
		else if(v[0]==c)
		{
    
      
			if(v[3]==b)puts("YES");
			else puts("NO");
		}
		else if(v[0]==d)
		{
    
      
			if(v[3]==a)puts("YES");
			else puts("NO");
		}
	}
}

https://codeforces.com/contest/1772/problem/C
题意:给出k,n,请构造出一个长度为k,元素范围在1-n的严格递增的数组,使它的后一项减去前一项的值 的集合元素个数最多。

思路:1、从最终的集合元素考虑,显然从1,2,3……这样开始构造更优。2、最坏的构造情况是,最后只能+1。
如果第1种的构造方法行不通的话,就用2。也就是说,从当前项(按第一种构造)推移到最后一项(按最坏的情况构造),当最后一项比n大时,说明该项开始就只能按第二种方法构造。

题意谁都懂,就是我脑子或者状态确实出了点问题。
好久没顾题时哪种类型的了。
这题贪心,政哥提醒的。

#include<bits/stdc++.h>
using namespace std;
#define int long long
int b[200005];
signed main()
{
    
      
	int tt;
	for(cin>>tt;tt--;)
	{
    
      
		int k,n;
		cin>>k>>n;
		b[1]=1,b[2]=2;
		int res=2;
		for(int i=3;i<=k;i++)
		{
    
      
			if(b[i-1]+res+k-i>n)//最后一项:此项加后面几项
			{
    
      
				for(int j=i;j<=k;j++)
					b[j]=b[j-1]+1;
				break;
			}
			else b[i]=b[i-1]+res,res++;
		}
		for(int i=1;i<=k;i++)
			cout<<b[i]<<' ';
		puts("");
	}
}