【Codeforces 1030D】Vasya and Triangle】的更多相关文章

[链接] 我是链接,点我呀:) [题意] 题意 [题解] 参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证mgcd(2n,k)/k是一个整数? 因为先前已经判断过 2nm/k是可以整除的. 显然k是被2n和m两个数字除了之后变成1 2n贡献的那一部分其实就是gcd(2n,k) 那么我们显然可以直接用gcd(2n,k)来代表2*n 所以右边肯定也是能整除的. 且<=m [代码] #include <bit…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 枚举三分线(离散后)的位置 然后根据预处理的前缀和,快速算出两个队伍的分数. [代码] #include <bits/stdc++.h> using namespace std; const int N = 2e5; int n,m; int a[N+10],b[N+10],aa[2*N+100],bb[2*N+100]; map<int,int> dic; map<int,int> dic2; int main…
[链接] 我是链接,点我呀:) [题意] [题解] 会发现两个皇后之间如果只有奇数个位置 也就是n%2==1 那么第二个人总是赢的 因为如果white往下跑的话,black也能往下跑. 第二个人没有输的机会. 其他情况就是第一个人赢了... [代码] import java.io.*; import java.util.*; public class Main { static InputReader in; static PrintWriter out; public static void…
链接 某个数x属于[1,n],至少询问哪些数“x是否是它的倍数”才能判断x.找出所有质因数和质因数的幂即可. #include<cstdio> #include<algorithm> #define N 1005 using namespace std; int n,pr[N],ans[N],cnt; int main(){ scanf("%d",&n); for(int i=2;i<=n;i++) if(!pr[i]) for(int j=i*2…
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=2000),问满足[数列长度是k && 数列中每一个元素arr[i]在1~n之间 && 数列中元素可以重复]的数列有多少个?结果对10^9+7取余 解题思路:dp[i][j]表示长度是j,最后一位是i的种数 if(kk%i==0) dp[kk][j+1]+=dp[i][j] #inc…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangl…
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard output Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many tri…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the meth…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The winter in Berland lasts n days. For each day we know the forecast for the average air temperature that day. Vasya has a new set of winter tir…
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q个操作; 有以下两种类型 ①将第i个连通块里面灯取反 ②询问你(x1,y1)(x2,y2)这个矩形区域内灯的权值的和; [题解] 要用到二维的树状数组; 取反操作只要O(1)就能完成; 即先不管它是什么,取反就是了; 然后在询问的时候,直接用二维树状数组累加; 这里的累加可能是减也可能是加; 也可能…