#include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<cmath> using namespace std; #define maxn 32800 int main() { int n,cnt,i,j;//筛法,不然超时 int a[maxn]={0}; for(i=2;i<maxn;i++) { for(j=i*2;j<max…
洛谷 1865 数论 线性素数筛法 最基本的线性素数筛法,当做复习欧拉筛法了,没有尝试过使用更暴力的筛法... WA了一次,手抖没打\n 传送门 (https://www.luogu.org/problem/show?pid=1865) #include <cstdio> #include <cstring> #include <algorithm> const int maxn = 1000000 + 500; int prime[maxn]; int isp[max…
Counting Divisors Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 3041    Accepted Submission(s): 1130 Problem Description In mathematics, the function d(n) denotes the number of divisors of…
ACM数论——素数  素数定义: 质数(prime number)又称素数,有无限个.质数定义为在大于1的自然数中,除了1和它本身以外不再有其他因数,这样的数称为质数.例 子:2.3.5.7.11.13.17.19.(那时候还有一种说法叫做“质数”,但是就语言上来说,我觉得“素数”这种叫法和“合数”比较搭配,类比于“化学元素”和“化合物”来看,叫“素数”非常贴切) 素数一些性质: 质数p的约数只有两个:1和p: 任一大于1的自然数,要么本身是质数,要么可以分解为几个质数之积,这种分解是唯一的:…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6069 题意: 给出 l, r, k.求:(lambda d(i^k))mod998244353,其中 l <= i <= r, d(i) 为 i 的因子个数. 思路:若 x 分解成质因子乘积的形式为 x = p1^a1 * p2^a2 * ... * pn^an,那么 d(x) = (a1 + 1) * (a2 + 1) * ... * (an + 1) .显然 d(x^k) = (a1 * k…
Prime Numbers  Descriptions: A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and p…
想要输出""的话: cout<<"A person whose name is \""<<name<<"\" and age is "<<age<<" is created!"<<endl; Home Web Board ProblemSet Standing Status Statistics   Problem G: 克隆人来了!…
这个题目主要是乘法运算符的重载,卡了我好久,矩阵的乘法用3个嵌套的for循环进行,要分清楚矩阵的乘法结果是第一个矩阵的行,第二个矩阵的列所组成的矩阵. 重载+,*运算符时,可以在参数列表中传两个矩阵引用,分别表示前后进行运算的矩阵,或者是只传运算符之后的矩阵引用,前一个矩阵用的是隐含的this指针指向的矩阵.我用的是后者. Home Web Board ProblemSet Standing Status Statistics   Problem G: 强悍的矩阵运算来了 Problem G:…
Problem G: Check The Check Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 10  Solved: 3[Submit][Status][Web Board] Description Your task is to write a program that reads a chessboard configuration and identifies whether a king is under attack (in chec…
在期末被各科的大作业碾压快要窒息之际,百忙之中抽空上牛客网逛了逛,无意中发现一道好题,NowCoder猜想,题意很明显,就是个简单的素数筛法,但竟然超内存了,我晕(+﹏+)~  明明有 3 万多 k 的空间限制……于是我不打表,试了试最暴力的做法,赤裸裸的做法果然超时了,无奈,只好对素数筛法进行位压缩了,这是我目前所能想到的方法了,第一次用上这样的特技,还是调了好一会(位数组里不能用 bool 来定义,具体的话好像 bool 和 int 之类的整型稍有不同:也不能用 int,因其最高位是正负标志…