Atcoder Beginner Contest 118】的更多相关文章

题目链接 题意就是给N根火柴,M个数(M只能是1到9,对应的数字也只能是1到9),只能用这M个出现过的数(但每个数可以随便用多少个,只要火柴够)来拼出一个数字(拼出1,2,3,4,5,6,7,8,9分别要用2,5,5,4,5,6,3,7,6根火柴),要求最大能拼出多大的数. 就是完全背包嘛,要是数字更大,数字长度必是首先要考虑的,再其次才是首位的数字大小. dp[i]表示由i根火柴能拼出的数字的最大长度,match数组就是上面那个对应关系,k表示要加上哪个数字, match[k]就是要这个数字需…
题目链接 题意就是要让给出的数字去互相取余,看看能得到最小的数事多少. 那么就可以从小到大排序,每一次都贪心地把最小的数作为攻击者,去攻击其他的数字(也就是大的取余小的),然后再一次排序,循环这个过程,直到出现1或者数字只剩一个非0数. 代码如下 #include <cstdio> #include <algorithm> using namespace std; ]; int main() { int n; scanf("%d", &n); ; i &…
A - B +/- A #include <bits/stdc++.h> int main() { int a, b; std::cin >> a >> b; b % a ? std::cout << b - a : std::cout << a + b; } B - Foods Loved by Everyone #include <bits/stdc++.h> int cnt[31], ans; int main() { int…
A: B +/- A 签到题. B: Foods Loved by Everyone 签到题. C: Monsters Battle Royale 怪物的血量一直两两相减,类似于辗转相减法. 可以证明,最后存活怪物血量最小值即为所有怪物初始血量的 \(gcd\) . D: Match Matching 考虑 \(dp\) 预处理一个数组 \(f\) , \(f[i][j]\) 表示第一位用数字 \(i\) ,后面一共用 \(j\) 根火柴棒,能拼出数字的最大位数. 一共有 \(nm\) 个状态,…
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E869120's and square1001's 16-th birthday is coming soon.Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces. E869…
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder Beginner Contest 052 A题意: 输出大的面积? 思路: max(A*B,C*D); AtCoder Beginner Contest 052 B题意: 枚举过程,然后...太水了.. AtCoder Beginner Contest 052 C题意: 输出N!的因子个数mod1…
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…
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…