0
点赞
收藏
分享

微信扫一扫

A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)

雷亚荣 2022-06-27 阅读 60

原题链接: ​​https://codeforces.com/contest/1443/problem/A​​

A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define
测试样例

input
3
2
3
4
output
6 4
4 6 10
14 10 12 8

题意: 给你一个整数A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define_02,现在你需要从编号A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_整除_03~A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define_04中选出A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define_02个编号使得这些编号之间A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_整除_06,不能整除。

解题思路: 这显然是一个构造问题,根据样例我们其实也能发现一些问题,如果A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_整除_06,那么A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_i++_08自然是大于1的数,而范围是A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define_04,又因为要选取A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_#define_02个编号,故我们的A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_i++_08只能限制在2,(即编号递增2)。那么还有一个要处理的地方就是不能整除,假设我定义好一个起始位置A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_i++_12,那么按照我们依次递增2,最后的编号为A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_整除_13,而起始位置的最小倍数也是在A. Kids Seating(构造)Codeforces Round #681 (Div. 2, based on VK Cup 2019-2020 - Final)_i++_14,所以必然不可能被整除 ,其他也一样。所以我们按这样构造即可解决问题。

AC代码

/*

*
*/
#include<bits/stdc++.h>//POJ不支持

#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=a;i>=n;i--)

using namespace std;

const int inf=0x3f3f3f3f;//无穷大。
const int maxn=1e5;//限定值。
typedef long long ll;

int t,n;
int main(){
while(cin>>t){
while(t--){
cin>>n;
cout<<2*n<<" ";
int temp=2*n;
rep(i,1,n-1){
temp+=2;
cout<<temp<<" ";
}
cout<<endl;
}
}
return 0;
}


举报

相关推荐

0 条评论