
cf
文章平均质量分 57
益达爱喝芬达
能摆就不要卷
展开
-
Sum of Consecutive Prime Numbers(尺取法)
Sum of Consecutive Prime Numbers(尺取法)题目描述Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5原创 2021-09-27 12:14:15 · 263 阅读 · 0 评论 -
D. Say No to Palindromes(前缀和)
D. Say No to Palindromes题目描述Let’s call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first character to the last and from the las原创 2021-09-16 09:20:23 · 229 阅读 · 0 评论 -
C. Jury Meeting
C. Jury Meeting(组合数)题目入口思路我们发现,每一次先消去的是最小的人,观察最后留下的两个不同的数,一定是最大的和次大的,并且我们发现,若最大的数个数多于两个,最后一定是在那几个数中循环,此时答案无关排列位置,就是n!,而当最大的数只有一个,以4 3 3 为例,只有当3 3 4时不合法,其余都合法,即最大数在所有次大数后面时不合法,答案用所有排列数减去不合法数即可(刚开始怕爆long long,用来qmul,结果反而tle了第8个点)代码#include<bits/std原创 2021-10-02 15:59:31 · 196 阅读 · 0 评论 -
2021-10-13 Codeforces Round #723 (Div. 2)
Codeforces Round #723 (Div. 2)A. Mean Inequality题目入口思路构造,本题保证各个数字均不相同,所以将数组排序后,对奇数位从小到大插入,对偶数位从大到小插入,能保证偶数位的值不是所有前后位相加除以2。代码#include<bits/stdc++.h>using namespace std;const int N=55;int n,a[N];int main(){ int t; cin>>t; w原创 2021-10-13 14:50:31 · 147 阅读 · 0 评论 -
2021-10-11Codeforces Round #731 (Div. 3)
Codeforces Round #731 (Div. 3)A. Shortest Path with Obstacle题目入口思路:特判一条线的情况,其他为曼哈顿距离代码#include<bits/stdc++.h>using namespace std;int main(){ int t; cin>>t; while(t--) { int x1,y1,x2,y2,x3,y3; cin>>x原创 2021-10-11 19:50:18 · 95 阅读 · 0 评论 -
Educational Codeforces Round 110 (Rated for Div. 2)
Educational Codeforces Round 110 (Rated for Div. 2)A. Fair Playoff题目入口思路找出最大和次大模拟即可代码#include<bits/stdc++.h>using namespace std;int a[5];int main(){ int t; cin>>t; while(t--) { int maxx=-1,max2=-1; for(原创 2021-10-09 14:14:47 · 140 阅读 · 0 评论 -
Codeforces Global Round 14
Codeforces Global Round 14A. Phoenix and Gold入口思路题目保证所有数字都不相同,只需要从小到大填数,若正好等于x,记录当前数并填下一个数即可代码#include<bits/stdc++.h>using namespace std;const int N=105;int a[N];int t,n,x;int main(){ cin>>t; while(t--) { cin>原创 2021-10-08 16:15:32 · 232 阅读 · 0 评论 -
E2. Array Optimization by Deque(树状数组)
E2. Array Optimization by Deque题目入口思路贪心+树状数组在每次加入一个数时比较加在头和尾时新增逆序对数即可,利用树状数组维护即可,由于求逆序对只需要知道数字比当前数大的有几个,即只需要知道他们之间的相对关系,因此首先将数组离散化。离散化模板 for(int i=1;i<=n;i++) { cin>>a1[i]; a2[i]=a1[i]; } sor原创 2021-10-02 14:46:22 · 360 阅读 · 0 评论 -
C. Carrying Conundrum(思维)
C. Carrying Conundrum(思维)题意小明不知道如何列竖式计算,每次计算将进位往左移了一位,要求算出存在多少对数对(a,b)使得其按照小明列竖式的方法能求出目标数字以下是小明的计算列竖式方法思路由于进位左移一位,也就是说个位进位到百位再进位到万位,十位进位到百位再到十万位,将奇数位和偶数位独立出来便是正确的列竖式方法,所以只需要将奇数位的组合与偶数位的组合个数相乘,由于本题要求数对(a,b)为正数,所以最后答案减2即可#include<bits/stdc++.h>原创 2021-09-15 20:59:12 · 260 阅读 · 0 评论 -
C. Rings(构造)
C. Rings(构造)https://codeforces.com/problemset/problem/1562/C题意Frodo was caught by Saruman. He tore a pouch from Frodo’s neck, shook out its contents —there was a pile of different rings: gold and silver…“How am I to tell which is the One?!” the mage ho原创 2021-09-15 22:14:55 · 278 阅读 · 0 评论 -
2021-09-17C. Strange Function(lcm+容斥)
C. Strange Function(lcm+容斥)题目入口思路f[x]表示不被x整除的最小的数,设其为a,则对x必存在因子1,2…a-1,也就是说x存在约数a1=lcm(1,2,3,…a-1),由于a不被整除,所以x不存在约数a2=lcm(1,2,…a),在1-n中a1的倍数有n/a1个,a2的倍数有n/a2个,由于a1|a2,所以是a1倍数但不是a2倍数的有n/a1-n/a2个,且这些数的大小为a,循环到lcm大于n的时候停止即可代码#include<bits/stdc++.h>原创 2021-09-17 09:41:11 · 231 阅读 · 0 评论 -
D1. Domino (easy version)(分解质因数+欧拉筛)
D1. Domino (easy version)题目入口思路设a=p1 ^ a1 * p2 ^ a2 * p3 ^ a3…pn ^ an (p1,p2…为a的质因数),b=k1 ^ b1 * k2 ^ b2 * k3 ^ b3…kn ^ bn (k1,k2…为b的质因数),则a可以在cnt1=a1+a2+a3…an的次数内变成1,b能够在 cnt2=b1+b2+b3…+bn的次数内变成1,于是可以发现,若k>cnt1+cnt2,两个数在cnt1+cnt2操作后无法操作,输出NO,在k<原创 2021-09-17 15:08:15 · 293 阅读 · 0 评论 -
B. Swaps(双指针)
B. Swaps(双指针)题目入口思路我们可以发现操作步数是由a移动的步数和b移动数量组成,为了使a严格小于b,由于a和b数组没有相同元素,所以必满足a[1]<b[1],而对于每个数组移动步数就是他们的坐标减1,暴力做法是我们枚举a的所有元素,再对b进行查找,这样复杂度O(n²),显然超时,若我们对a数组进行排序,并且记录他的原坐标,再对b数组进行查找,由于a数组满足a[i[<a[i+1],因此若b[j]>a[i],则当a到a[i+1]时,b中j前面的元素一定小于a[i+1],于是原创 2021-09-24 14:40:11 · 284 阅读 · 0 评论