造福后人之随机数据生成器
  • 板块P5217 贫穷
  • 楼主AFewSuns
  • 当前回复4
  • 已保存回复4
  • 发布时间2021/11/3 08:13
  • 上次更新2023/11/4 01:32:10
查看原帖
造福后人之随机数据生成器
224336
AFewSuns楼主2021/11/3 08:13

RT,给某些调了很久调不出来的人

#include<bits/stdc++.h>
#define ll long long
#define random(x) rand()*rand()%(x)
using namespace std;
ll n=10,m=10,tot;
int main(){
	srand((unsigned)time(NULL));
	freopen("1.in","w",stdout);
	printf("%lld %lld\n",n,m);
	tot=n;
	for(ll i=1;i<=n;i++){
		char c=(char)('a'+random(26));
		cout<<c;
	}
	printf("\n");
	while(m--){
		ll opt=random(6)+1;
		if(!tot){
			if(opt<=3) opt=1;
			else opt=4;
		}
		if(opt==1){
			printf("I ");
			ll x=random(tot+1);
			char c=(char)('a'+random(26));
			cout<<x<<" "<<c<<endl;
			tot++;
		}
		if(opt==2){
			printf("D ");
			ll x=random(tot)+1;
			printf("%lld\n",x);
			tot--;
		}
		if(opt==3){
			printf("R ");
			ll x=random(tot)+1,y=random(tot)+1;
			if(x>y) swap(x,y);
			printf("%lld %lld\n",x,y);
		}
		if(opt==4){
			printf("P ");
			ll x=random(n)+1;
			printf("%lld\n",x);
		}
		if(opt==5){
			printf("T ");
			ll x=random(tot)+1;
			printf("%lld\n",x);
		}
		if(opt==6){
			printf("Q ");
			ll x=random(tot)+1,y=random(tot)+1;
			if(x>y) swap(x,y);
			printf("%lld %lld\n",x,y);
		}
	}
}
2021/11/3 08:13
加载中...