AGC 022 B - GCD Sequence】的更多相关文章

题面在这里! 锻炼脑子的小构造题... 一开始被 a[]<=30000 且 序列 gcd = 1所困扰,但是发现这并没有什么,因为我接下来发现了一种总是能构造出 序列和是6的倍数的方案. 首先如果 n==3 的话输出样例,因为只有这种情况没法用我的方法构造. 否则,考虑两个集合,第一个集合 A 代表<=30000的所有偶数,显然 |A| = 15000: 第二个集合 B 代表 <=30000的所有非偶数的3的倍数,显然 |B| = 5000. 神奇的发现 |A| + |B|  = n可以…
A.QAQ 题目大意:从给定的字符串中找出QAQ的个数,三个字母的位置可以不连续 思路:暴力求解,先找到A的位置,往前扫,往后扫寻找Q的个数q1,q2,然 后相乘得到q1*q2,这就是这个A能够找到的QAQ个数,依次累加即可 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin>>s;…
C. Marco and GCD Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a dream Marco met an elderly man with a pair of black glasses. The man told him the key to immortality and then…
C. Marco and GCD Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output In a dream Marco met an elderly man with a pair of black glasses. The man told him the key to immortality and then…
题目链接:https://cn.vjudge.net/problem/CodeForces-894C In a dream Marco met an elderly man with a pair of black glasses. The man told him the key to immortality and then disappeared with the wind of time. When he woke up, he only remembered that the key…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把gcd(a[1..n])放在输入的n个数之间. [代码] /* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the solution is right? At least,the main ideal 4.use the puts("")…
题目链接:http://codeforces.com/contest/894/problem/C 题目大意: 按照严格递增的顺序给出 \(m\) 个数作为公因数集,请你构造出一个数列,对于数列中的任意连续子段,其公因数都在题目给出公因数集中:如果无法构造出合格的数列则输出 “-1” . 知识点: (void) 解题思路: 如果公因数集中最小的数不能整除集合中的所有数,则输出 “-1”,设最小的数是 \(x_{1}\),其不能整除的数是 \(x_{i}\) ,很明显你构造出来的数列中一定存在 \(…
题面在这里! 显然权值是 2^i 这种的话就是要你贪心,高位能不选就不选. 并且如果 % x 之后再去 % 一个>=x的数是没有用的,所以我们可以把操作的k看成单调递减序列. 这样的话就是一个有向图联通性问题了,直接做就可以了. #include<bits/stdc++.h> #define ll long long using namespace std; int n,a[55],b[55]; bool v[55][55]; ll ans=0; inline bool can(){ m…
A - Diverse Word Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes th…
BC都被hack的人生,痛苦. 下面是题解的表演时间: A. QAQ "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of leng…