CA Loves GCD (BC#78 1002) (hdu 5656)】的更多相关文章

CA Loves GCD  Accepts: 135  Submissions: 586  Time Limit: 6000/3000 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 CA喜欢是一个热爱党和人民的优秀同♂志,所以他也非常喜欢GCD(请在输入法中输入GCD得到CA喜欢GCD的原因). 现在他有N个不同的数,每次他会从中选出若干个(至少一个数),求出所有数的GCD然后放回去. 为了使自己不会无聊,C…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5656 bc:http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=683&pid=1002 CA Loves GCD Accepts: 64    Submissions: 535 Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/2…
CA Loves GCD  Accepts: 64  Submissions: 535  Time Limit: 6000/3000 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描述 CA喜欢是一个热爱党和人民的优秀同♂志,所以他也非常喜欢GCD(请在输入法中输入GCD得到CA喜欢GCD的原因). 现在他有N个不同的数,每次他会从中选出若干个(至少一个数),求出所有数的GCD然后放回去. 为了使自己不会无聊,CA…
CA Loves GCD 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5656 Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are N different numbers. Each time, CA will select s…
CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1707    Accepted Submission(s): 543 Problem Description CA is a fine comrade who loves the party and people; inevitably she loves G…
CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 882    Accepted Submission(s): 305 Problem Description CA is a fine comrade who loves the party and people; inevitably she loves GC…
CA Loves GCD 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/B Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are different numbers. Each time, CA will se…
CA Loves GCD Accepts: 135 Submissions: 586 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) 问题描述 CA喜欢是一个热爱党和人民的优秀同♂志,所以他也非常喜欢GCD(请在输入法中输入GCD得到CA喜欢GCD的原因). 现在他有N个不同的数,每次他会从中选出若干个(至少一个数),求出所有数的GCD然后放回去. 为了使自己不会无聊,CA会把每…
题目链接: CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others) Problem Description   CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there ar…
Problem Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are N different numbers. Each time, CA will select several numbers (at least one), and find the GCD of these n…
题目的意思就是: n个数,求n个数所有子集的最大公约数之和. 第一种方法: 枚举子集,求每一种子集的gcd之和,n=1000,复杂度O(2^n). 谁去用? 所以只能优化! 题目中有很重要的一句话! We guarantee that all numbers in the test are in the range [1,1000]. 1 1 这句话对解题有什么帮助? 子集的种数有2^n种,但是,无论有多少种子集,它们的最大公约数一定在1-1000之间. 所以,我们只需要统计1-1000的最大公…
题意:给定一个数组,每次他会从中选出若干个(至少一个数),求出所有数的GCD然后放回去,为了使自己不会无聊,会把每种不同的选法都选一遍,想知道他得到的所有GCD的和是多少. 析:枚举gcd,然后求每个gcd产生的个数,这里要使用容斥定理,f[i]表示的是 gcd 是 i 的个数,g[i] 表示的是 gcd 是 i 倍数的,f[i] = g[i] - f[j] (i|j). 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000&qu…
一道我想骂人的题,差点把我气炸了. 题意: 求一个数的集合中(非多重集,每个数只出现一次)所有子集的gcd的和.结果MOD10^8+7输出. 输入输出不说了,自己看吧,不想写了. 当时我真把它当作数论题来写了,以为可以推导出什么公式然后化简大量重复的操作的.结果最后也没找到.最后题解说是dp,我同学说是暴力,吐血10升. 然后弄出来dp方程之后还是反复的wa,方程明明没啥问题,愣是卡了2个小时找不出错误,心情烦躁的要命,坑爹的室友还各种看视频打游戏,还不带耳机,我自己只好带着耳机大声放音乐,最后…
CA Loves GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 809    Accepted Submission(s): 283 Problem Description CA is a fine comrade who loves the party and people; inevitably she loves GC…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5656 CA Loves Stick Accepts: 381   Submissions: 3204 Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 262144/262144 K (Java/Others) 问题描述 CA喜欢玩木棍. 有一天他获得了四根木棍,他想知道用这些木棍能不能拼成一个四边形.(四边形定义:https://e…
CA Loves Stick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 981    Accepted Submission(s): 332 Problem Description CA loves to play with sticks.One day he receives four pieces of sticks, he…
CA Loves Palindromic Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 301    Accepted Submission(s): 131 Problem Description CA loves strings, especially loves the palindrome strings. One day…
CA loves strings, especially loves the palindrome strings. One day he gets a string, he wants to know how many palindromic substrings in the substring S[l,r] . Attantion, each same palindromic substring can only be counted once. InputFirst line conta…
Count the Sheep Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 484    Accepted Submission(s): 212 Problem Description Altough Skipping the class is happy, the new term still can drive luras an…
BestCoder Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 573    Accepted Submission(s): 201 Problem Description Mr Potato is a coder.Mr Potato is the BestCoder. One night, an amazing s…
题意: 给出\(A(2 \leq A \leq 11), n(0 \leq n \leq 10^9), k(1 \leq k \leq 10^9)\). 求区间\([1, A^n]\)中各个数字互不相同的\(A\)进制数而且是\(k\)的倍数的个数. 分析: 如果\(n > A\),根据抽屉原理,\(n\)位\(A\)进制数一定会有重复的数字. 所以下面只讨论\(n \leq a\)的情况. 对于\(k\)的大小,分别使用不同的算法: \(k\)比较小的时候,用状压DP:\(d(S, x)\)表…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发现问题了,想对自己说是不是撒 首先最好从大的那个开始考虑,我的方案就是两数交换一下,结果输出的时候没有考虑... 然后就是要求a+b最小,那么循环就要从大的开始向小的循环. 其实我也解释不清楚,更解释不清楚的是学长取名的Baby Nero,一直以为铭铭姐是女的的我,在看到真的铭神的照片的时候惊呆了…
Description Mr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Greatest Common Divisor Query (RGCDQ). What’s RGCDQ? Please let me explain it to you gradual…
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 240 Problem Description This is a simple problem. The teacher gives Bob a list of prob…
Ch’s gift Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1354    Accepted Submission(s): 496 Problem Description Mr. Cui is working off-campus and he misses his girl friend very much. After a w…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2668    Accepted Submission(s): 562 Problem Description Sample Input 1 a 2 aa bb 3 a ba abc Sample Output Case #1: 25 Case #2: 132…
点开BC发现今晚没比赛..然后似乎上一场有数位DP?...(幸好我没去 一开始被BCDcode那题的思路带歪了..后来发现得把n转成二进制才能搞TAT 题目大概是要求一种类似逆序对的鬼东西: 有一个长度为 n 的数组 A(下标为 1 到 n),A_i​​ 为 i 的二进制表示中的1的个数,例如 A[1]=1, A[3]=2, A[10]=2. 现在勇太想知道数组 A 中满足 A[ i ]>A[ j ] 的数对 ( i , j )(1 ≤ i < j ≤ n) 的个数. f[i][j]表示二进制…
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-si…
Skip the Class Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 253    Accepted Submission(s): 146 Problem Description Finally term begins. luras loves school so much as she could skip the class…
代码引用kuangbin大神的,膜拜 第一次见到hashmap和外挂,看来还有很多东西要学 维护前缀和sum[i]=a[0]-a[1]+a[2]-a[3]+…+(-1)^i*a[i] 枚举结尾i,然后在hash表中查询是否存在sum[i]-K的值. 如果当前i为奇数,则将sum[i]插入到hash表中. 上面考虑的是从i为偶数为开头的情况. 然后再考虑以奇数开头的情况,按照上述方法再做一次即可. 不同的是这次要维护的前缀和是sum[i]=-(a[0]-a[1]+a[2]-a[3]+…+(-1)^…