https://www.luogu.com.cn/problem/P11003 一道思维题,画图就可以:
n为1:1种。为2:两种。为3:3种。为4:4种…以此类推。
结论:如果n是3的倍数,输出n*2,否则输出n。
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll t,n;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--){
cin>>n;
if(n%3==0){
cout<<n*2<<'\n';
}else{
cout<<n<<'\n';
}
}
return 0;
}