题解:P12408 始终
本题题意非常清楚,在此不赘述了。
思路分析
当 -1。样例也体现了这个结论。
题目背景中“以我为始,以我为终”提示答案或许与循环有关。事实也确实如此。
在较小的正整数中,
Code
#include<bits/stdc++.h>
using namespace std;
constexpr int num[]={2,6,12,6};
int main(){
ios::sync_with_stdio(false),
cin.tie(nullptr),cout.tie(nullptr);
int n;cin>>n;
if(n==2)cout<<"-1";
else for(int i=1;i<=n;++i)cout<<num[i&3]<<' '; //i & 3 == i % 4
return 0;
}