题意就是标题. 思路: 对于每个数 a 算出 1~a 的所有因数和sum(a),输出sum(b)-sum(a-1). 关键在于如何求出 sum. 首先发现因数∈ 1 ≤ i ≤ n ,每个因数在区间[1,n]内的出现次数(不考虑4=2*2这样因数重复出现,这种情况2只算出现一次)等于 n/i (向下取整). 然后用 t = n/(n/i) 可以找到与因数i出现次数相同的最大因数(这里可能有点难理解,例如1~100区间内21作为因数出现的数字有 21 ,42 ,63 ,84:即四次.按计算机整数相…
题目链接: 2018 ICPC Pacific Northwest Regional Contest - I-Inversions 题意 给出一个长度为\(n\)的序列,其中的数字介于0-k之间,为0表示这个位置是空的.现在可以在这些空的位置上任意填入1-k之间的数字(可以重复).问最多可以总共有多少对逆序对.(如果\(i<j,p_i>p_j\),则称\((i,j)\)是一对逆序对) \(1\leq n\leq 2*10^5,\ 1\leq k\leq 100\) 思路 第一步,先证明最优的填…
2018-2019 ACM-ICPC Pacific Northwest Regional Contest (Div. 1) 思路: A Exam 思路:水题 代码: #include<bits/stdc++.h> using namespace std; int main(){ int k; scanf("%d",&k); ],s2[]; scanf("%s%s",s1,s2); ; int n=strlen(s1); ;i<n;i++)…
题目:https://vj.69fa.cn/12703be72f729288b4cced17e2501850?v=1552995458 dp这个题目网上说是dp+离散化这个题目要对这些数字先处理然后进行dp,这个处理值得学习一下,就是把数字范围为1~1e9,转化成一个顺序列表,这个顺序列表每一个不同的位置含有不同的难度,dp[i][j]代表前面i种选出j种的方案数. #include <cstdio> #include <iostream> #include <cstdlib…
A:Alphabet Solved. 签. #include<bits/stdc++.h> using namespace std; ]; ]; int main(){ scanf(); ); ;i<=n;i++) { f[i]=; } ;i<=n;i++) { ;j<i;j++) { if(s[i]>s[j]){ f[i]=max(f[i],f[j]+); } } } ; ;i<=n;i++) { maxn=max(maxn,f[i]); } cout<&…
SurfNow that you've come to Florida and taken up surng, you love it! Of course, you've realized thatif you take a particular wave, even if it's very fun, you may miss another wave that's just aboutto come that's even more fun. Luckily, you've gotten…
[题目链接] A - Alphabet 最长公共子序列.保留最长公共子序列,剩余的删除或者补足即可. #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; char s[maxn]; char t[maxn]; int dp[100][100]; int main() { scanf("%s", s); for(int i = 0; i < 26; i ++) { t[i] =…
A:Exam Solved. 温暖的签. #include<bits/stdc++.h> using namespace std; ; int k; char str1[maxn], str2[maxn]; int main() { while(~scanf("%d",&k)) { scanf(); scanf(); , cnt2 = ; ); ; i <= len; ++i) { if(str1[i] == str2[i]) cnt1++; else cnt…
题目链接:http://codeforces.com/gym/101201 /* * @Author: lyucheng * @Date: 2017-10-22 14:38:52 * @Last Modified by: lyucheng * @Last Modified time: 2017-10-22 16:37:43 */ /* * 题意:2^k次方个人两两进行淘汰赛,排名高的人一定能胜过排名低的人,问你排名r的人的胜场期望 * * 思路:首先,如果r想赢i场的话那么一定要和2^i - 1…
A. Odd Palindrome 所有回文子串长度都是奇数等价于不存在长度为$2$的偶回文子串,即相邻两个字符都不同. #include<cstdio> #include<cstring> char a[1111111];int n,i; int main(){ scanf("%s",a+1); n=strlen(a+1); for(i=1;i<n;i++)if(a[i]==a[i+1])return puts("Or not."),…