AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsundoku D - Sum of Divisors E - NEQ F - Unfair Nim A - Calc 程序如下(真的有人需要嘛): #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdi…
比赛链接:https://atcoder.jp/contests/abc172/tasks A - Calc 题意 给出一个正整数 $a$,计算 $a + a^2 + a^3$ .($1 \le a \le 10$) 代码 #include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; cout << a + a * a + a * a * a; } B - Minor Change…
题意:在\(x\)轴上,你刚开始在\(0\)的位置,第\(i\)次操作需要走\(A_1,...,A_i\)个单位,如果\(A_i\)为正向右走,否则向左走,求你所能走到的最大坐标. 题解:我们一步一步来看: 第一次走:\(A_1\). 第二次走:\(A_1,A_2\). . . . 第\(n\)次走:\(A_1,A_2,...,A_n\). 在某次刚开始走的时候,我们的贡献应该是上一次走完的贡献,分别加上\(A_1,...,A_i\),而最大值就产生在这个过程中,如果暴力遍历的话必然超时,我们可…
题意:有一长度为奇数\(n\)的数组\(a\),和长度为\(m\)的数组\(b\),现要求从\(b\)中选择一个数放到\(a\)中,并将\(a\)分成\((n+1)/2\)个数对,求最小的所有数对差的和. 题解:我们从\(b\)中选一个数出来,只和\(a\)中的一个元素配对,剩下的依然是\(a\)中\(n-1\)个数两两配对,所以我们可以先求个前缀/后缀和,然后枚举\(b\)在\(a\)中二分查找和\(b_i\)最近的数,但是会有个小问题,加入我们二分查找的位置是偶数,此时并不能完全配对,但是没…
A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even o…
Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K. Here, a checked pattern of side K is a pattern where each square is painte…
A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contest, AtCoder Beginner Contest, is abbreviated as ABC. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example,…
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) oth…
KYOCERA Programming Contest 2021(AtCoder Beginner Contest 200) 题解 哦淦我已经菜到被ABC吊打了. A - Century 首先把当前年份减去\(1\),对应的世纪也减去\(1\),然后我们就发现第\(0\)到\(99\)年对应第\(0\)世纪,第\(100\)到\(199\)年对应第\(1\)世纪,以此类推. 答案就是\(\lfloor \frac {N-1} {100} \rfloor\).这里\(\lfloor x \rflo…
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…