7.23暑假集训

作者分享了参加编程竞赛的经历,包括比赛中遇到的问题,如心态影响表现,以及对题目解法的思考。文章提到了在A题和B题上的策略,C题的构造方法,并反思了在解决某些问题时的不足,如过度关注排名和没有充分利用时间。作者还提到了其他选手更简洁的解题方案,并表示会继续努力提升技能。
摘要由CSDN通过智能技术生成

咖啡还是比较人性化的..昨天还放了半天假,在宿舍玩了一晚上....

还有还打了一场div2,结果掉大分了...

过了2题,排名4000名,结果被hack掉了..无语死了....

cf掉到了1200分一下了...

本想着想上个1400的...结果感觉不太行啊...

自己太菜了...其实吧我感觉自己不是很菜的...就是比赛的时候太注意自己和自己队友的standing了...无法静下心来认真思考啊...这就很尴尬了啊...

自己的实力还是有的,继续加油吧,失败总是贯穿人生始终!

CF877:

A:

A还是比较水的..给你2个数字,然后进行n-2次操作,每次操作从序列中选2个数,然后求他们差的绝对值然后放入序列

思路:先对n-2次得到的序列排序,如果a[1]为负数就直接输出,否则输出最大的

B:

B题想了半天...我真的是吐了.....题目就不翻译了...想了半天应该怎么搞怎么搞...

最后恍然大悟..因为排列个数一定大于等于1,我们只需在1和2之间插入n即可

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
int n;
int main(){
	
	scanf("%d",&t);
	
	while(t--){
		scanf("%d",&n);
		int pos1,pos2,pos3;
		int x;
		if(n==1){
			printf("1 1\n");
			continue;
		}
		
		for(int i=1;i<=n;i++){
			scanf("%d",&x);
			if(x==1){
				pos1=i;
			}
			if(x==2)pos2=i;
			if(x==n)pos3=i;
		}
		
		if(pos3>=pos1&&pos3<=pos2||(pos3<=pos1&&pos3>=pos2)){
			printf("1 1\n");
			continue; 
		}
		
		if(pos3<pos1&&pos3<pos2){
			int minn=min(pos1,pos2);
			printf("%d %d\n",pos3,minn);
		}
		if(pos3>pos1&&pos3>pos2){
			int minn=max(pos1,pos2);
			printf("%d %d\n",pos3,minn);
		}
	}
	

	
	
	return 0;
}

 

没想出来...我是菜鸡...

C:

构造题..

最近一直在刷构造...有时感觉自己构造很强,有时感觉自己拉跨的要死...

这场比赛也是....比赛中途感觉自己做不出来就出去玩了....玩了20分钟左右把...回来之后就立马有思路了....

但是没在比赛截至前交上,在20分钟之后才交上的

如果n和m有一个不为素数的话就很好做

如果m不为素数:直接1 2 3  4 

                                    5 6 7 8

                                    ...  .. .  n*m  即可了.因为上下差值为m为素数..

如果n不为素数:直接1  6 

                                   2  7

                                   3   8

                                   4    9

                                   5

                                      即可了.因为左右差值为n不为素数..

如果n和m都为素数的话.

我们可以构造假设     i*n+(1,2,3,....m)

                    我们可以先将i为奇数的放在上面,将i为偶数的放在下面即可,

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int t;
int n,m;
int a[1005][1005];
bool isprime(int n){
	
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)return 1;
	}
	
	return 0; 
}
int main(){
	scanf("%d",&t);
	while(t--){
		
		scanf("%d%d",&n,&m);
		int flag=0;
		
		if(isprime(m)){
			flag=1;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++){
					a[i][j]=(i-1)*m+j;
				}
			}
		}
		
		
		if(flag==0){
			if(isprime(n)){
				flag=1;
				for(int j=1;j<=m;j++){
					for(int i=1;i<=n;i++){
						a[i][j]=(j-1)*n+i;
					}
				}
			}	
		}
		
		
		if(flag==0){
			int cnt1=0;
			int cnt2=0; 
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++){
					if(i<=n/2){
						a[i][j]=j+(2*i-1)*m;
					}else{
						a[i][j]=j+(2*(i-n/2)-2)*m;
					}
				}
			}
		}
		
		
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				printf("%d ",a[i][j]);
			}
			printf("\n");
		}
		
		
	}
	

	return 0;
}

 

我写的及其麻烦...

看看陆爹的:

一边处理一边输出即可..

#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<cstring>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const int N=1e6+10;
const int M=1e6+10;
const ll MOD=998244353;
const int INF=0x7fffffff;//2^31-1 <==> 2e9+
const ll LINF=0x7fffffffffffffff;//2^63-1 <==> 9e18+
bool isnprime[1010];
int primes[1010];
int cnt=0;
void init(){
	isnprime[1]=true;
	isnprime[2]=false;
	for(int i=2;i<=1000;i++){
		if(!isnprime[i]){
			primes[cnt++]=i;	
		}
		for(int j=0;j<cnt;j++){
			if(primes[j]*i>1000) break;
			isnprime[primes[j]*i]=true;
			if(i%primes[j]==0) break;
		}
	}
}

int a[1010][1010];

void solve(){
	int n,m;
	cin>>n>>m;
	if(isnprime[m]){
		for(int i=0;i<n;i++){
			for(int j=1;j<=m;j++){
				cout<<(i*m)+j<<" \n"[j==m];
			}
		}
		return;
	}
	if(isnprime[n]){
		for(int i=1;i<=n;i++){
			for(int j=0;j<m;j++){
				cout<<i+j*n<<" \n"[j==m-1];
			}
		}
	}else{
		for(int i=0;i<n;i+=2){
			for(int j=1;j<=m;j++){
				cout<<i*m+j<<" \n"[j==m];
			}
		}
		for(int i=1;i<n;i+=2){
			for(int j=1;j<=m;j++){
				cout<<i*m+j<<" \n"[j==m];
			}
		}
	}
}

signed main(){
	ios::sync_with_stdio(NULL);
	cin.tie(nullptr);
 	cout.tie(nullptr);
	init();
	int T=1;
	cin>>T;
	while(T--){
		solve();
	}
}

CF887

昨天晚上打的..感觉状态还行....但B被hack了.www....

A:签到题目

不说了...

B:我感觉B读题就读了5分钟...可算是读懂了..

一开始我的思路就是对的...但是..

我们设前2项为f1, f2

3   f1+f2

4   :f1+2f2

5   :2f1+3f2

6  :3f1+5f2

我们发现第n项的f1的系数和f2的系数满足斐波那契...

所以我们就可以打表了..

设xf1+yf2=n...我一开始就想到这了....

然后我就开始慌了这不说扩展欧几里得..我不会啊...这做啥啊...

然后我又去想别的思路了..

然后兜兜转转都回来了..

我发现可以枚举...

好欸..结果我双层循环枚举f1和f2...今早直接被hack了

其实只需枚举f1即可,然后f2就知道了..

注意f2>=f1这一项即可

		#include<cstdio>
		#include<cmath>
		#include<iostream>
		#include<algorithm>
		#include<string.h>
		#include<queue>
		#include<stack>
		#include<deque>
		#include<vector>
		#include<map>
		#include<set>
		#include <utility>
		#include <list>
		using namespace std;
		typedef  long  long ll ;
		typedef  unsigned long  long ull ;
		#define pii pair<int,int>
		const int inf = 0x3f3f3f3f;//106110956
		inline int read(){
		    int x = 0, f = 1;
		    char ch = getchar();
		    while(ch < '0' || ch > '9'){
		        if (ch == '-')
		            f = -1;
		        ch = getchar();
		    }
		    while(ch >= '0' && ch <= '9'){
		        x = (x<<1) + (x<<3) + (ch^48);
		        ch = getchar();
		    }
		    return x * f;
		}
		void print(__int128 num) {
			if(num) {
				print(num/10);
				putchar(num%10+'0');
			}
		}
		ll ex_gcd(ll a,ll b,ll& x,ll& y){
			if(b==0){
				x=1;
				y=0;
				return a;
			}
		
			ll d=ex_gcd(b,a%b,y,x);
			y=y-a/b*x;
			return d;
		}
		int a[35]={0,1,0,1};
		int b[35]={0,0,1,1}; 
		int t;
		int main(){
			
			for(int i=4;i<=31;i++){
				a[i]=a[i-1]+a[i-2];
			}
			
			for(int i=4;i<=31;i++){
				b[i]=b[i-1]+b[i-2];
			}
			
			scanf("%d",&t);
			
			while(t--){
				ll ans=0;
				ll n,k;
				scanf("%lld%lld",&n,&k);
				
				if(k>=30){
					printf("0\n");
					continue;
				}
				
				for(int i=0;i<=n/a[k];i++){
					
					ll now=n-i*a[k];		
					if(now%b[k]==0&&now/b[k]>=i)ans++;
			
				}
				
				printf("%lld\n",ans);
				
			}
			
			return 0;
		}
		
		

C题通过量太离谱了...看我队友会不会吧

昨天和今天做了2个1400构造都没出来...

哭...

1103A:

这题其实很好写的..思路来的也很快,也错的快..

最重要的是横着的方块和竖着的方块的方法..

一开始我都是从左上到右上放的...

结果wa14了..然后从右下往左上也wa14

....其实我有很多极端情况没有考虑周全

一种可行的方法就是横着放左下,竖着放右上

1088C:

一道很好的题目...可惜也没做出来啊.

起初我想的是先mod1,然后全变成0,然后(昨天没写完今天继续,感觉要困死了,每天睡觉的时间都太少了...今晚上又有cfdiv3了...)感觉不能熬夜了....熬夜睡觉时间完全不够啊哭死...

然后从n到1加n-1,然后再模n...结果步数超了..这就很尴尬了..

然后自己又想了一会没有思路,就看答案了..

答案是n+1步,把n到1的每一位都没变i-1,我们要从后往前做,防止后面对前面造成影响

我们设sum为前面所有操作加上数的综合,add为这次加数的和

然后我们可知:(a[i]+sum+add)%n==i-1

故add=(i-1-(a[[i]+sum)%n+n)%n

然后就构造好了    

#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<stack>
#include<deque>
#include<vector>
#include<map>
#include<set>
#include <utility>
#include <list>
using namespace std;
typedef  long  long ll ;
typedef  unsigned long  long ull ;
#define pii pair<int,int>
const int inf = 0x3f3f3f3f;//106110956
inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}
void print(__int128 num) {
	if(num) {
		print(num/10);
		putchar(num%10+'0');
	}
}
ll ex_gcd(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}

	ll d=ex_gcd(b,a%b,y,x);
	y=y-a/b*x;
	return d;
}
int a[2005];
int main(){
	int n;
	
	scanf("%d",&n);
	
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	
	printf("%d\n",n+1);
	
	ll sum=0;
	
	for(int i=n;i>=1;i--){ 
		
		int add=(i-1-(a[i]+sum)%n+n)%n;
		
		printf("1 %d %d\n",i,add);
		
		sum=sum+add;
		
	}
	
	printf("2 %d %d\n",n,n);
	

	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值