Codeforces Round #654 (Div. 2) B. Magical Calendar (结论)

-
题意:你需要在长度从\(1\)~\(k\),宽度无限的网格图中造图形(每个点四周必须连通),问最多能造出多少种不同的图形.
-
题解:感觉没什么好说的,就是画图找规律,如果\(r\ge n\)的话(即没有任何空间限制),那么就是1+1+....+n-1,否则就被网格图限制了,这时的方案数只能是1+2+....+r.
-
代码:
int t; ll n,r; int main() { ios::sync_with_stdio(false);cin.tie(0); cin>>t; while(t--){ cin>>n>>r; if(r>=n){ cout<<n-1+(n-1)*(n-2)/2+1<<endl; } else{ cout<<r+(r)*(r-1)/2<<endl; } } return 0; }
𝓐𝓬𝓱𝓲𝓮𝓿𝓮𝓶𝓮𝓷𝓽 𝓹𝓻𝓸𝓿𝓲𝓭𝓮𝓼 𝓽𝓱𝓮 𝓸𝓷𝓵𝔂 𝓻𝓮𝓪𝓵
𝓹𝓵𝓮𝓪𝓼𝓾𝓻𝓮 𝓲𝓷 𝓵𝓲𝓯𝓮

浙公网安备 33010602011771号