题解 ARC115C【ℕ Coloring】

显然 A1,A2,A4,A8, 必须互不相同,因此最大的数一定不小于 log2n+1,猜想可以取到 log2n+1

构造 Ai=log2i+1,则对于任意 Ai=Aj 都有 2i>j,不存在倍数关系。

时间复杂度 Θ(n)

// Problem: C - ℕ Coloring
// Contest: AtCoder - AtCoder Regular Contest 115
// URL: https://atcoder.jp/contests/arc115/tasks/arc115_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//By: OIer rui_er
#include <bits/stdc++.h>
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define debug(format...) fprintf(stderr, format)
#define fileIO(s) do{freopen(s".in","r",stdin);freopen(s".out","w",stdout);}while(false)
using namespace std;
typedef long long ll;

template<typename T> void chkmin(T& x, T y) {if(x > y) x = y;}
template<typename T> void chkmax(T& x, T y) {if(x < y) x = y;}

int main() {
	int n;
	scanf("%d", &n);
	for(int L = 1, R, u = 1; L <= n; L = R + 1, u++) {
		R = 2 * L - 1;
		chkmin(R, n);
		rep(i, L, R) printf("%d%c", u, " \n"[i==n]);
	}
	return 0;
}
posted @   rui_er  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示