题意:
给出n,k;
输出n组集合,每组4个。
对于任意一组中的4个元素,一组内任意2个数的gcd==k
且n组的所有数字不能重复。
要使得n组中最大的数字最小。
并输出n数数组
思路:
显然输出的只是每四个互质的数,与k无关
规律居然是:
从一开始 【1 2 3 3+2】 上次最后的数是5,然后【5+2 8 9 9+2】
for (i=1;i<=n;i++)
{
printf("%d %d %d %d\n",st*k,(st+1)*k,(st+2)*k,(st+4)*k);
st+=6;
}
跪了。。。。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
int main()
{
int i;
int n,k;
scanf("%d%d",&n,&k);
int st=1;
printf("%d\n",(6*(n)-1)*k);
for (i=1;i<=n;i++)
{
printf("%d %d %d %d\n",st*k,(st+1)*k,(st+2)*k,(st+4)*k);
st+=6;
}
return 0;
}