造福后人(数据生成器)
查看原帖
造福后人(数据生成器)
613794
jianhe楼主2024/11/12 18:52

注意到数据中有指数里带 + 号的以及指数为负数的。写到生成器里去了(除了 BBBB 表示 B2B^2 之类的没写)。

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=4,M=2,P=11;//N: 式子数 M: 每个式子的最长长度 P: 系数/指数 的最大值
ll tot,t;
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("data.in","w",stdout);
	srand(time(0));
	for(int i=1;i<=N;i++){
		tot=rand()%M;t=rand()%(2*P)-P;cout<<t<<" ";
		for(int j=1;j<=tot;j++){	
			t=rand()%26;cout<<(char)('A'+t);
			t=rand()%(2*P)-P;cout<<"^";
			if(t>0&&(rand()&1)) cout<<"+";cout<<t;
			if(j!=tot||i!=N) cout<<" ";
		}
		if(i!=N) cout<<"+ ";
	}
	cout<<"\n";
	for(int i=1;i<=N;i++){
		tot=rand()%M;t=rand()%(2*P)-P;cout<<t<<" ";
		for(int j=1;j<=tot;j++){	
			t=rand()%26;cout<<(char)('A'+t);
			t=rand()%(2*P)-P;cout<<"^";
			if(t>0&&(rand()&1)) cout<<"+";cout<<t;
			if(j!=tot||i!=N) cout<<" ";
		}
		if(i!=N) cout<<"+ ";
	}
	return 0;
}

2024/11/12 18:52
加载中...