regionals multiply contest problem

AtCoder Regular Contest 125 E Snack

洛谷传送门 AtCoder 传送门 很棒的 flow 题,考虑建二分图。 源点向每种零食连边权为 $a_i$ 的边,每种零食向每个孩子连边权为 $b_j$ 的边,每个孩子向汇点连边权为 $c_j$ 的边,这个图的最大流就是答案。 直接跑最大流肯定 T,考虑最大流等价于求这个图的最小割,因此转而求最小 ......
AtCoder Regular Contest Snack 125

AtCoder Regular Contest 126 D Pure Straight

洛谷传送门 AtCoder 传送门 很不错的状压。 考虑先把最后作为答案的数聚到一起,再算它们的逆序对个数。 设 $f_S$ 为当前选的数集合为 $S$ 的答案。有转移: 选 $a_i$,答案加上之前选的比它大的数; 不选 $a_i$,此时需要把左边的数或者右边的数往中间挪一个,答案加上左右两端的最 ......
Straight AtCoder Regular Contest Pure

SMU Spring 2023 Trial Contest Round 9

A. Wrong Subtraction 在k次操作里, 将n的最后一位数减1,如果是0就去掉,模拟一下就好了. #include <bits/stdc++.h> //#define inf 0x3f3f3f3f #define endl '\n' #define int long long usi ......
Contest Spring Round Trial 2023

Problem A. Restoring Numbers

Problem A. Restoring Numbers Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after tha ......
Restoring Problem Numbers

SMU Spring 2023 Trial Contest Round 10

SMU Spring 2023 Trial Contest Round 10 A - Remove Duplicates #include<bits/stdc++.h> using namespace std; typedef pair<int,int>PII; typedef pair<strin ......
Contest Spring Round Trial 2023

AtCoder Beginner Contest 159

AtCoder Beginner Contest 159 https://atcoder.jp/contests/abc159 EF 是打基础的好题 D - Banned K #include <bits/stdc++.h> #define ll long long using namespace ......
Beginner AtCoder Contest 159

SMU Spring 2023 Trial Contest Round 10

A. Remove Duplicates #include <bits/stdc++.h> using namespace std; #define int long long int read() { int x = 0, f = 1, ch = getchar(); while ((ch < ' ......
Contest Spring Round Trial 2023

Problem H: 超时计时器设置

Problem Description 运输层的超时计时器的超时重传时间应设置为多大呢? 如果把超时重传时间设置得太短,就会引起很多报文段的不必要的重传,使网络负荷增大。但若把超时重传时间设置得过长,则又使网络的空闲时间增大,降低了传输效率。 TCP 采用了一种自适应算法,它记录一个报文段发出的时间 ......
计时器 Problem

Problem G: 距离向量算法(D-V)

Problem Description RIP路由协议是一种分布式的基于距离向量的路由选择协议。距离向量(D-V)算法:收到相邻路由器(设其地址为 X)的一个 RIP 报文: ① 先修改此 RIP 报文中的所有项目:把“下一跳”字段中的地址都改为 X,并把所有的“距离”字段的值加 1。 ② 对修改后 ......
向量 算法 Problem D-V

Problem J: base64解码

Problem Description 对于任意二进制文件(如图像、声音、视频、程序等),都可以用base64编码。base64编码方法:先把二进制代码划分为一系列24位长的单元,然后把每一个24位单元划分为4个6位的组。每一个6位组按下列方法转换为ASCII码。6位二进制有64个不同的值,0-63 ......
Problem base 64

Problem I: base64编码

Problem Description 对于任意二进制文件(如图像、声音、视频、程序等),都可以用base64编码。base64编码方法:先把二进制代码划分为一系列24位长的单元,然后把每一个24位单元划分为4个6位的组。每一个6位组按下列方法转换为ASCII码。6位二进制有64个不同的值,0-63 ......
编码 Problem base 64

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

Problem F: 计算地址掩码和地址数

1 def INTO(list): 2 sum = 0; 3 length = len(list) 4 for i in range(length): 5 sum+=list[i]*pow(2,i) 6 return sum 7 #计算地址掩码 8 def caculate(a): 9 x = in ......
地址 Problem

Problem C: 以太网交换机转发数据帧

1 def MacAdress(m): 2 ad = [] 3 while m>0: 4 m-=1 5 #将一行mac地址拆分进数组a中 6 a = input().split(" ",3) 7 ad.append(a) 8 return ad 9 10 def Frame(n): 11 frame ......
以太网 交换机 Problem 数据

Problem B: 以太网交换机的自学习算法

1 def func(): 2 lines = [] 3 while True: 4 try: 5 #x作为中间量更新交换表的端口号 6 x = input() 7 if x ==' ': 8 break 9 x = x.split(' ', 3) 10 11 flag = 0 12 # 利用enu ......
以太网 交换机 算法 Problem

Problem E: 计算网络地址

1 def calculate(m,n): 2 ans = [] 3 a = m.split('.',3) 4 b = n.split('.', 3) 5 ip = list(map(int,a)) 6 mask = list(map(int, b)) 7 for i in range(4): 8 ......
Problem 地址 网络

Problem D: IP地址合法性和网络类别检查

1 def Islegal(a): 2 ip = list(map(int,a)) 3 flag = 0 #标志是否合法 4 if 0<=ip[0]<=255: 5 if 0<=ip[1]<=255: 6 if 0 <= ip[2] <= 255: 7 if 0 <= ip[3] <= 255: 8 ......
合法性 类别 Problem 地址 网络

AtCoder Problem Difficulty

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

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

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

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)](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; ......

模拟赛 & 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