[CodeForces 1141A] Game 23】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/1141/A 首先,nn一定要是mm的倍数.否则就无法转换,输出-1: 然后令k=.\frac{m}{n} ,即k=.\frac{m}{n} . 将k 分解质因数,若分解结果是k=.\frac{m}{n} ,那答案就是k=.\frac{m}{n} . 如果无法分解成k=.\frac{m}{n} ,那么输出-1. AC代码: #include <cstdio> using namespace std; i…
https://codeforces.ml/contest/1746/problem/D 题目大意:一棵n节点有根树,根节点为1,分别有两个数组 s[i] 顶点 i 的魅力值 c[i] 覆盖顶点 i 的路径数 每个顶点的路径数必须满足,同一父节点的子节点| c[v1]-c[v2] | <= 1 问当有k条路径时,∑c[i]*s[i]的最大值 思路: 因为同一父节点的子节点 | c[v1]-c[v2] | <= 1,所以对于父节点来说,每次都需要平分路径数,如果有多余的路径则考虑 分给贡献最大的…
CodeForces 22A 找严格第二小的...注意只有一种情况,可以sort排序然后unique输出. int a[N]; int main() { int n; while(~scanf("%d",&n)) { for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); if(n==1||a[0]==a[n-1]) printf("NO\n"); else { unique…
A emmmmmmmmm B emmmmmmmmm C(套路) 题意: 给定n和s(n,s<=1e18),计算n以内有多少个数x满足(x-x的各个位置数字之和)>=s 分析: 容易想到如果x相对于s很大很大,那么肯定是满足条件的 那些小于s的数,肯定是不行的 于是x就可以从s开始,往后枚举1e6个,去判定这1e6个有多少个是满足条件的,再往后的那些x肯定是满足的,直接算出多少个就行了 D(插板法) 题意: 给定一个长度为n(n<=1e6)的数列,对于这个数列的一个连续的子列,定义valu…
https://vjudge.net/problem/CodeForces-1141A #include <bits/stdc++.h> using namespace std; int a,b; int main(){ scanf("%d%d",&a,&b); ){ //先判断m能不能整除n printf("-1"); ; } b=b/a; //除得两者相差的倍数 a=; ==) b=b/,a++; //除去b因数中所有的2 ==) b…
比赛链接 A 题解 知识点:贪心,构造. 注意到有 \(1\) 就一定能构造. 时间复杂度 \(O(n)\) 空间复杂度 \(O(1)\) 代码 #include <bits/stdc++.h> #define ll long long using namespace std; bool solve() { int n, k; cin >> n >> k; bool ok = 0; for (int i = 1;i <= n;i++) { int x; cin &…
链接:https://codeforces.com/contest/1141/problem/A 题意: 给n和m,有两种操作:将n×2 或 n×3,求最少的乘法次数由n得到m. 不能得到时为-1. 思路: 先判断是否为整数倍. 再将倍数不断除以2和3. 最后剩下1则可以达到否则-1. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; int main() { int n, m; cin >&g…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups,…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment. Amr has n different types of chemicals. E…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vanya has a scales for weighing loads and weights of masses w0,?w1,?w2,?-,?w100 grams where w is some integer not less than 2 (exactly one weight…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office. All chi…
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…
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks…
B. Makes And The Product time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn'…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
F. MEX Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a set of integer numbers, initially it is empty. You should perform n queries. There are three different types…
E. Choosing The Commander time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires…
D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the differenc…
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks…
传送门 考试的时候卡了一会儿. 显然这个答案只跟二进制位为1的数量有关. 还有一个显然的结论. 对于一个区间[l,r][l,r][l,r],如果其中单个数二进制位为1的数量最大值不到区间所有数二进制位为1的数量之和的一半即maxn∗2≤summaxn*2\le summaxn∗2≤sum,并且sum是偶数那么这个区间是好的. 继续考虑,如果我们枚举左端点l和右端点r,那么当sum[r0]−sum[l−1]≥64sum[r_0]-sum[l-1]\ge 64sum[r0​]−sum[l−1]≥64…
传送门 今天的签到题. 有一个很显然的结论,gcd(n∗m,k)≤2gcd(n*m,k)\le 2gcd(n∗m,k)≤2. 本蒟蒻是用的行列式求三角形面积证明的. 如果满足这个条件,就可以直接构造出一个满足限制的直角三角形了. 代码: #include<bits/stdc++.h> #define ll long long using namespace std; inline ll read(){ ll ans=0; char ch=getchar(); while(!isdigit(ch…
传送门 线段树维护区间取模,单点修改,区间求和. 这题老套路了,对一个数来说,每次取模至少让它减少一半,这样每次单点修改对时间复杂度的贡献就是一个log" role="presentation" style="position: relative;">loglog,所以维护区间最大值剪枝,然后每次单点暴力取模,这样的话时间复杂度为O(nlogn)" role="presentation" style="posi…
昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int x1,x2,yy1,y2,x,y; int main(){ scanf("%d%d%d%d%d%d&qu…
A题 分析:注意两个点之间的倍数差,若为偶数则为YES,否则为NO #include "iostream" #include "cstdio" #include "cstring" #include "string" #include "cmath" using namespace std; int main() { int x1,y1,x2,y2; cin>>x1>>y1>&…
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; int main() { int sa,sb,da,db,x,y; scanf("%d%d%d%d%d%d",&sa,&sb,&da,&db,&x,&y); sa=da-sa;sb=db-sb; if(sa<0)sa*=-1; if(…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, -, an, where…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output As Famil Door's birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His friends are going to buy a string cons…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output International Abbreviation Olympiad takes place annually starting from 1989. Each year the competition receives an abbreviation of form IAO'y, wh…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of…