生成测试数据
[cpp]#include<time.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<cstdio>
using namespace std;
double random()
{return (double)rand()/RAND_MAX;}
int random(int m)
{
return (int)(random()*(m-1)+0.5);
}
int n,m;
void in(int &a)
{
char ch;
while((ch=getchar())<'0'||ch>'9');
for(a=0;ch>='0'&&ch<='9';ch=getchar()) a=a*10+ch-'0';
}
int main()
{
srand(time(NULL));
int T;
in(T);
freopen("1.txt","w",stdout);
printf("%d\n",T);
while(T--)
{
in(m),in(n);
printf("%d\n",m);
for(int i=0;i!=m;++i)//m代表有多少组,n代表数据的范围。
[cpp] view plaincopy
{
int x;
int y;
bool flag=false;
if(rand()%2) flag=true;
while(1)
{
x=random(n)+1;
y=random(n)+1;
if(x!=y&&x&&y) break;
}
if(i%2==1&&flag) x=-x,y=-y;
else if(i%2==1&&!flag) x=-x;
else if(i%2==0&&flag) y=-y;
printf("%d %d\n",x,y);
}
}return 0;
作者:smallacmer
补充:软件开发 , C++ ,