beginner atcoder contest 147

Educational Codeforces Round 147

A 题意 思路 有前导零结果直接为0,出现在第一位的**?贡献为9**,其他地方的**?贡献为10**。 代码 #include<bits/stdc++.h> using namespace std; using ll=long long; char s[10]; int main() { int ......
Educational Codeforces Round 147

Educational Codeforces Round 147 (Rated for Div. 2)

题目链接 B 核心思路 真的需要加强了,看到这个最大值和最小值我们其实也需要往对应的最大值和最小值的相关操作去想,不如前缀最小值/前缀最大值或者是后缀最小值/后缀最大值。 这里一个比较直接的想法就是想找到不同的地方,然后看不可以扩展。那么怎么看是否可以扩展呢,如果是左边的话,就看当前的位置是不是小于 ......
Educational Codeforces Round Rated 147

AtCoder Beginner Contest 158

AtCoder Beginner Contest 158 https://atcoder.jp/contests/abc158 基础不牢,地动山摇 D - String Formation 一个小小的STL应用 #include <bits/stdc++.h> #define ll long lon ......
Beginner AtCoder Contest 158

AtCoder Problem Difficulty

ABC299 之前 . ......
Difficulty AtCoder Problem

Educational Codeforces Round 147 (A-D)

#A. Matching 橘子熊:这题太简单了我不想写 ##题面 Description 给定给一个带问号的字符串,求有多少种可能的数字 Input 多次询问,一次一个字符串 Output 对于每次询问,输出可能的数字的总数 数据范围与约定 2e5次询问,单词询问不超过5个字符 ##思路 主要思路 ......
Educational Codeforces Round 147 A-D

AtCoder ABC 299 ABCDEFG

A - Treasure Chest 题意 给定由 $\texttt{.}$、$\texttt{|}$、$\texttt{}$ 三种字符组成的长度为 $n$ 的字符串 $s$,保证 $\texttt{|}$ 的个数为 $2$,$\texttt{}$ 的个数为 $1$。 判断 $\texttt{*}$ ......
AtCoder ABCDEFG ABC 299

AtCoder Regular Contest 111 F Do you like query problems?

洛谷传送门 AtCoder 传送门 挺有意思的计数。 计数感觉很难做,不妨转成期望,期望又可以转成概率之和。 考虑枚举 $w \in [0,m-1]$,把 $> w$ 的数设为 $1$,$\le w$ 的数设为 $0$。那么期望就是所有 $w$,$a_i$ 为 $1$ 的概率之和。对于一个 $i$, ......
problems AtCoder Regular Contest query

Atcoder题解:Agc056_e

$$也想养老鼠捏$$ 先把当前要解决的点旋转到位置 $n$,问题不变。求 $n$ 次即可。 我们先来看两个没有结果的解法。 一就是一 我们先考虑暴力 $dp$,设 $dp_{i,mask}$ 表示当前已经安放了 $i$ 个奶酪,被喂饱的老鼠的集合为 $mask$ 的概率。容易发现 $i$ 其实就是 ......
题解 Atcoder Agc 056

Educational Codeforces Round 147 (Rated for Div. 2) A-D题解

A. Matching 题意:给出一个数,数中可能会有?,可以用0-9替换问号,问最后有多少种方法 Solution 对于位于首位的数可以用1-9替换,对于其他位置的额、可以用0-9替换,如果首位为0则无解 void solve() { string s;cin>>s; if(s[0]=='0') ......
题解 Educational Codeforces Round Rated

SMU Spring 2023 Trial Contest Round 9

SMU Spring 2023 Trial Contest Round 9 A - Wrong Subtraction #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<string ......
Contest Spring Round Trial 2023

SMU Spring 2023 Trial Contest Round 9

A. Wrong Subtraction #include <bits/stdc++.h> using namespace std; int32_t main() { int n, k; cin >> n >> k; while (k--) { if (n % 10 == 0) n /= 10; e ......
Contest Spring Round Trial 2023

Atcoder Beginner Contest 299 G

对于要打印的 $B$,我们首先尝试确定 $B_1$。 让 $f(x) (1≤x≤M)$ 是最大的 $i$,使 $A_i = x$。 对于 $r:=\underset{{{1≤x≤M}}}{\min}f(x)$,我们可以证明 $B_1$ 是 $A_1 ,A_2 ,...,A_r$ 中的一个(否则,$B ......
Beginner Atcoder Contest 299

AtCoder Beginner Contest 299

A - Treasure Chest (abc299 a) 题目大意 给定一个包含 |*.的字符串,其中|两个,*一个,问*是否在两个|之间。 解题思路 找到两个|的下标$l, r$以及 *的下标$mid$,看看是否满足 $l < mid < r$即可。 神奇的代码 ```cpp #include ......
Beginner AtCoder Contest 299

AtCoder Beginner Contest 283 Ex Popcount Sum

洛谷传送门 AtCoder 传送门 记录一下这个神奇的套路。 首先有 $\operatorname{popcount}(n) = n - \sum\limits_{i=1}^{\infty} \left\lfloor\frac{n}{2^i}\right\rfloor$。证一下: $$\operat ......
Beginner Popcount AtCoder Contest 283

CF ER147 div.2

A 简单计数题,判断前导零。 #include <bits/stdc++.h> using namespace std; int T; int main(){ cin >> T; while(T --){ char s[10]; cin >> s; int n = strlen(s); int an ......
147 div CF ER

AtCoder Regular Contest 115 D Odd Degree

洛谷传送门 AtCoder 传送门 若连通块是一棵树,考虑钦定 $k$ 个点为奇度点,方案数为 $\binom{n}{k}$。对于叶子,如果它是奇度点,那么连向它父亲的边要保留,否则不保留。这样自底向上考虑,任意一条边的保留情况都可以唯一确定,所以最后方案数就是 $\binom{n}{k}$。 若连 ......
AtCoder Regular Contest Degree 115

AtCoder Regular Contest 114 F Permutation Division

洛谷传送门 AtCoder 传送门 这题居然是之前某场模拟赛(contest 701)的 T1……(@Vidoliga 场切但是被卡常/bx) 下面记 $m$ 为原题面中的 $K$,$a_i$ 为原题面中的 $P_i$。 不难发现后手的策略是把所有段按照段的第一个数从大到小排序接在一起。 考虑若 $ ......
Permutation Division AtCoder Regular Contest

AtCoder Regular Contest 114 D Moving Pieces on Line

洛谷传送门 AtCoder 传送门 挺有意思的题。 首先显然地,一个棋子不会走回头路。于是一个棋子沿着边走的效果就是区间异或。 更进一步,设 $s_i$ 为 $i-1 \to i$ 的边颜色与 $i \to i+1$ 的边颜色是否相同(差分),相当于对于每个 $i$ 都选择 $s_{a_i}$ 和 ......
AtCoder Regular Contest Moving Pieces

Educational Codeforces Round 147 (Rated for Div. 2) A ~ C

A. Matching 题意:   给定一个字符串,将其中的 ‘?’ 替换成数字,不含前导0,如果字符串前导为0,输出0.。 分析:   每个地方有10种可能方案,在特判一下第一位就行了。 ......
Educational Codeforces Round Rated 147

Educational Codeforces Round 147 (Rated for Div. 2)

Educational Codeforces Round 147 (Rated for Div. 2) 链接 Educational Codeforces Round 147 (Rated for Div. 2) A题 如果第一位数是0,直接打印0 如果第一位数是'?',有9个数可以选择,如果其他位 ......
Educational Codeforces Round Rated 147

[Educational Codeforces Round 147 (Rated for Div. 2)](https://codeforc.es/contest/1821)题解A~D

A: 思路: 首字母如果是0,直接输出0。 如果首字母是?,提供九种方案,之后每一个?提供10种方案。 void solve(){ string s; cin>>s; if(s[0]=='0'){ cout<<"0"<<endl; return ; } int ans=1; for(int i=0; ......

练习记录-cf-Educational Codeforces Round 147 (A-D)

打的很烂的一场 C想了很久 D的贪心没有贪好 赛后一小时补起来了 谁是nc 我是nc! A. Matching 问有多少种情况能匹配 就计算?的个数 x10x10...... 如果第一个是? 那么就是9x10x10... 如果第一个是0 不能有前导0 就输出0 #include<bits/stdc+ ......

模拟赛 & VP & Contest 记录

CatOJ C140(初中) $100+93+100+10=303$,Rank 1。 是个 dp 场,A 题期望 dp,B 题神奇猜结论,C 题换根 dp,D 题树上博弈 dp。 A 题设 $f_u$ 为填满子树 $u$ 的期望次数,$s_u$ 为 $u$ 子树大小,容易得到 $f_u=f_v+\f ......
模拟赛 amp Contest VP

Atcoder Beginner Contest 298---E

题目:E - Unfair Sugoroku (atcoder.jp) 分析:这题状态转移方程挺好推的,但是用dp解是我没想到的 dp[i][j][0]表示T在i点,A在j点且轮到T走时赢的概率 dp[i][j][1]表示T在i点,A在j点且轮到A走时赢的概率 代码: #include <bits/ ......
Beginner Atcoder Contest 298

Atcoder题解:Agc018_f

首先观察这个奇怪的子树为 $1$ 或 $-1$ 的限制。 看不出来性质,润了。 我们不如直接把 $A$ 树和 $B$ 树拆开,变成两棵树,然后在树上留一下匹配的性质。 第一,我们对着样例构造一下,发现似乎有解的样例都有 $abs(X_i)\le 1$ 的解。 这就提示我们猜用 $-1,0,1$ 就够 ......
题解 Atcoder Agc 018

AtCoder Regular Contest 109 F 1D Kingdom Builder

洛谷传送门 AtCoder 传送门 考虑判断一个终止态是否可达。如果只有一个棋子连续段那一定可达;否则就存在 $\ge 2$ 个连续段。此时把放棋子看成删除,那么限制就是如果删除一个孤立的棋子(两边没有棋子)且还有别的格子有棋子,这个棋子的颜色 异于其他连续段的两边棋子的颜色 。 设第一个被删的段( ......
AtCoder Regular Contest Builder Kingdom

AtCoder Beginner Contest 298

A - Job Interview #include <bits/stdc++.h> using namespace std; int main(){ int n; string s; cin >> n >> s; if( s.find("x") != -1 ){ printf("No\n"); } ......
Beginner AtCoder Contest 298

Atcoder Regular Contest 118 E - Avoid Permutations(容斥+DP)

挺套路的 DP。 第一步是显然的:转换贡献体,DP 一条从 $(0,0)$ 到 $(n+1,n+1)$ 的路径,然后计算有多少个排列满足这条路径不经过任何一个 $(i,p_i)$。 正着统计肯定不好求,考虑容斥。即我们钦定一些路径上的点,满足这些点必须对应某个 $(i,p_i)$,然后计算有多少个 ......
Permutations Atcoder Regular Contest Avoid

Atcoder题解:Agc010_e

首先,我们来思考我们要构造的是什么。 我们要构造的是一个无论怎样操作字典序都会变小的序列,且这个序列的字典序是最小的。 然后考虑字典序会变大的条件。 如果字典序变大了,那么一定是在前 $i-1$ 位不变的前题下,$i$ 位的变大了。那么变大的一定是从后面来的。 而我们考虑所有的数对 $(a_i,a_ ......
题解 Atcoder Agc 010

abc292[AtCoder Beginner Contest 292] 题解

写点题目转换下心情吧 A-CAPS LOCK 大水题 B-Yellow and Red Card 大水题 C-Four Variables 给定一个数$N$,问有多少个有序正数数组$(A,B,C,D)$,满足$A\times B+C\times D=N$。 这题荒芜的大脑拒绝思考,看着复杂度不超,写 ......
题解 292 Beginner AtCoder Contest