跳到正文

题解

题解:P11003 [蓝桥杯 2024 省 Python B] 蓝桥村的真相

yinmingyang01约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年8月30日
收录
2025年12月12日
更新
2026年9月6日
篇幅
约 1 分钟
题目
P11003

版本

  1. v2当前
  2. v1

https://www.luogu.com.cn/problem/P11003 一道思维题,画图就可以:

n为1:1种。为2:两种。为3:3种。为4:4种…以此类推。

结论:如果n是3的倍数,输出n*2,否则输出n。

C++
#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;
}
原文