题意:给你n和k,然后让你找出n个数使得gcd(a1,a2)+gcd(a3,a4)+......的和等于k;
思路:如果n为奇数,让前n-3个数的相邻两个数都为1,n-2和n-1两个数gcd为k-ans;ans为前n-3个数的和。为偶数的话,让前n-2个数的相邻两个数都为1,n和n-1两个数gcd为k-ans;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#define maxn 10000
#define ll long long
using namespace std; int n,k;
vector<int>q; int main()
{
scanf("%d%d",&n,&k);
if((n%==&&(n/)>k)||(n%!=&&(n-)/>k))
{
printf("-1\n");
}
else
{
if(n==&&k==)
{
printf("1\n");
return ;
}
else if(n==&&k>)
{
printf("-1\n");
return ;
}
if(n%==)
{
int ans=;
ll c=;
for(int i=; i<=n-; i+=)
{
printf("%lld %lld ",c,c-);
c-=;
ans++;
}
printf("%lld %lld\n",(ll)(k-ans),(ll)((k-ans)*));
}
else
{
int ans1=;
ll c1=;
for(int i=; i<n-; i+=)
{
printf("%lld %lld ",c1,c1-);
c1-=;
ans1++;
}
printf("%lld %lld",(ll)(k-ans1),(ll)(k-ans1)*);
printf(" %lld\n",c1);
}
}
return ;
}