1. 程式人生 > 實用技巧 >Codeforces Round 662 賽後解題報告

Codeforces Round 662 賽後解題報告

Codeforces Round 662 賽後解題報告

夢幻開局到1400+的悲慘故事

A. LCM Problem

這個題很簡單,我們可以畫幾張圖,發現每一次我們染色的最佳方法就是每次往裡面多填一圈,並把上一圈給填滿。

比如上圖就很好地說明了這個過程,大家可以用畫一下 \(n=4,n=5,n=6,n=7\),就能驗證這個命題了,所以一個 \(n\times n\) 的矩陣有 \(\lfloor\frac{n}{2}\rfloor+1\) 圈,所以直接輸出即可。

//Don't act like a loser.
//You can only use the code for studying or finding mistakes
//Or,you'll be punished by Sakyamuni!!!
//#pragma GCC optimize("Ofast","-funroll-loops","-fdelete-null-pointer-checks")
//#pragma GCC target("ssse3","sse3","sse2","sse","avx2","avx")
#include<bits/stdc++.h>
#define int long long
using namespace std;

int read() {
	char ch=getchar();
	int f=1,x=0;
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return f*x;
}

int n;

signed main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	int t=read();
	while(t--) {
		n=read();
		
		cout<<n/2+1<<endl;
	}

	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


Keep updating qwq