csu 1756: Prime】的更多相关文章

1756: Prime Submit Page   Summary   Time Limit: 3 Sec     Memory Limit: 128 Mb     Submitted: 281     Solved: 69 Description 如果a,b的最大公约数是1,说明a,b是一对互素的数,给定你n个数字,希望你找出互素的数的对数 Input 第一行输入一个正整数T,表示数据组数 每组数据第一行输入一个正整数n,表示数字的个数(n<=10000) 接下来一行输入n个正整数,每个数字大…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1756 直接暴力O(n^2logn)过不了 两两算gcd 考虑每个数的范围[1,1000]统计一下即可O(1000^2*log(1000)) Notice:1与任何数互质,需要特判(自己与自己互质) Code1 统计 // <1756.cpp> - Wed Oct 19 08:25:53 2016 // This file is made by YJinpeng,created by XuYik…
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1425 DP题. f[i][j]表示当前数字为i,分解式中最大质数为j的方案数,那么,状态转移方程为: f[i][j] = sum(f[i-j][k]) 其中,k为小于等于j的所有质数. 求具体分解式时可以先转化为从小到大(如样例的“顺数第2”可以表述为“倒数第3”),更容易递推编程. #include <stdio.h> #include <string.h> #defi…
Prime Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 84  Solved: 12[Submit][Status][Web Board] Description 如果a,b的最大公约数是1,说明a,b是一对互素的数,给定你n个数字,希望你找出互素的数的对数 Input 第一行输入一个正整数T,表示数据组数 每组数据第一行输入一个正整数n,表示数字的个数(n<=10000) 接下来一行输入n个正整数,每个数字大小不超过1000. Output 输…
这个题本来有希望在比赛里面出了的 当时也想着用递推 因为后面的数明显是由前面的推过来的 但是在计算的时候 因为判重的问题 ...很无语.我打算用一个tot[i]来存i的总种树,tot[i]+=tot[j]//j为可以由j推到i的一系列数,但这样是不对的,会产生大量重复计算... 看了下标程才发现要用二维来计算出种类总数,f[i][j]+=sum(f[i-j][k]) 表示在推i数的时候,第一个素数为j的种类数,注意j一定为素数,而且k不能大于j...标程里面处理的比较简练,就学了下他的写法. 至…
Description xrdog has a number set. There are 95 numbers in this set. They all have something in common and are all positive integers less than 500. The naughty xiao zhuan has deleted one of the numbers in the set. Can you find the number that xiao z…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1552 Description On an alien planet, every extraterrestrial is born with a number. If the sum of two numbers is a prime number, then two extraterrestrials can be friends. But every extraterrestr…
Description: Count the number of prime numbers less than a non-negative number, n click to show more hints. Credits:Special thanks to @mithmatt for adding this problem and creating all test cases. 求n以内的所有素数,以前看过的一道题目,通过将所有非素数标记出来,再找出素数,代码如下: public i…
Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases in a single line (t<=10). In each of the next t li…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…