Atcoder Beginner Contest 299 G】的更多相关文章

随机 + 数论 题意 Submission #35524126 - AtCoder Beginner Contest 272 给一个长度为 \(n\;(1<=n<=5000)\) 的数组 \(a[i]\),求一个 \(3<=M<=10^9\), 使得有 \(\lfloor\frac {n}{2}\rfloor+1\) 个数在 \(\mod M\) 意义下的值相同 思路 如果随机取两个数,都是那 \(\lfloor\frac {n}{2}\rfloor+1\) 个数的几率是 \(\f…
题目传送门:G - Scalene Triangle Area (atcoder.jp) 题意: 给定大小为N*N的OX矩阵,若矩阵的(s,t)处为O,其覆盖范围为:满足以下条件的所有位置(i,j) s <= i && t <= j (i - s) + (j - t) / 2 < M 再给出Q次询问,对于每次询问(x,y),要求给出对应位置被覆盖了多少次. 思路:imos 不妨先考虑 n = 7, m = 3, 且仅在左上角处为 'O' .那么矩阵上每个位置被覆盖次数如T…
套路题 题意 求有多少个 \(1\) 到 \(n\) 的排列满足恰有 \(k\) 对在排列中相邻的数满足前小于后 \(2 \leq n \leq 500, 0 \leq k \leq (n - 1)\) 思路 f[i][j][k] 表示已经放置了前 i 个数, 放置的第i个数是前i个数中第j大的($ 1\leq\(`j`\)\leq$i),已放置的前i个数形成的所有排列满足恰有 k 对在排列中相邻的数满足前小于后的排列数量. 放置第i+1个数时,第i+1个数是前i+1个数中第j大的,第i个数是严…
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; cout &…
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) \[x=i,g(x)=0\] \[x\ne i ,g(x)=1\] 则我们可以构造 \[f(x)=\sum^{i=0}_{P-1}(-a_i*(x-i)^{P-1}+a_i)\] 对于第\(i\)条式子当且仅当\(a_i=1 \ and \ x=i\)时取到\(1\) 代码写的比较奇怪 const…
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takahashi is a user of a site that hosts programming contests.When a user competes in a contest, the rating of the user (not necessarily an integer) changes…
AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low[u]指dfs栈中u能追溯到的最早栈中节点从次序号.这里写的很好. #include<bits/stdc++.h> using namespace std; ; vector<int> G[maxn]; int dfn[maxn],low[maxn]; int n,m,u,v,dep,…
人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We have A balls with the string S written on each of them and B balls with the string T written on each of them. From these balls, Takahashi chooses one…
AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C - Sum of product of pairs D - Friends E - Coprime F - I hate Shortest Path Problem A - Don't be late 问你能不能在时间\(T\)内用不高于\(S\)的速度走过\(D\)的路程,转化为判断\(ST\)…
小兔的话 欢迎大家在评论区留言哦~ AtCoder Beginner Contest 168 A - ∴ (Therefore) B - ... (Triple Dots) C - : (Colon) D - .. (Double Dots) E - ∙ (Bullet) 简单题意 小兔捕获了 \(N\) 条不同的沙丁鱼,第 \(i\) 条沙丁鱼的 美味程度 和 香味程度 分别是 \(A_i\) 和 \(B_i\) 她想在这些沙丁鱼中选择 一条 或者 多条 放入冷冻箱:但是必须保证沙丁鱼的选择是…