diverta 2019 Programming Contest 2 A - Ball Distribution 特判一下一个人的,否则是\(N - (K - 1) - 1\) #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ')…
diverta 2019 Programming Contest 因为评测机的缘故--它unrated了.. A - Consecutive Integers #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define…
AtCoder diverta 2019 Programming Contest 2 看起来我也不知道是一个啥比赛. 然后就写写题解QWQ. A - Ball Distribution 有\(n\)个气球\(k\)个人,每个人至少要拿一个气球.问所有分配方案中拿走气球最多的那个人可以比最少的那个人多拿多少个. 打比赛的时候一开始没看到题,别人说输出\(n\% k\)就过了,然后我就过了. 现在重新一看题解... 应该是\(k=1\)时,答案是\(0\),否则答案是\(n-k\). #includ…
ExaWizards 2019 C - Snuke the Wizard 发现符文的相对位置不变,直接二分某个位置是否到达最左或最右来计算 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putc…
A 签到(a-b problem不用贴了吧,以后atcoder小于300分题均不贴代码) B 发现选择的p,q一定是其中两点间的距离,于是可以O(n2)枚举两点,再O(n2)判断,其实可以做到O(n3)不过O(n4)就够了. #include<bits/stdc++.h> using namespace std; typedef long long ll; int n,ans; ll x[],y[]; int main() { scanf("%d",&n); ans…
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;} int gcd(int n…
A:签到. #include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000010 char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;} int gcd(int n…
[题解]CF1056F Write the Contest(三分+贪心+DP) 最优化问题的三个解决方法都套在一个题里了,真牛逼 最优解应该是怎样的,一定存在一种最优解是先完成了耗时长的任务再干别的(不干白不干啊),所以我们按照耗时先排序. 假设你最优解是去事件\(e_1,e_2,e_3,e_4\),你可以在规定时间里干完,那么你如果按照耗时从大往小干也一定可以干完. 好像只能找到"按照耗时从大往小干"一种钦定方法使得所有方案可以归纳到这种情况 考虑最终耗时是怎样的:\(t\)表示练习…
M-SOLUTIONS Programming Contest A - Sum of Interior Angles #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ') #define enter putchar('\n') #…
[题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n).n<=200000. [算法]二分+模拟 [题解]将答案分成(A[i]+B[j]-A[i]^B[j])的异或和 以及 A[i]^B[j]的异或和,即单独考虑进位(后面部分很好算). 二进制题目必须拆位,通过进位使第k位+1的数对必须满足 ( A[i] & ((1<<k)-1) )…