题目链接:https://cn.vjudge.net/problem/LightOJ-1336 题意 给出一个区间[1, n],求区间内所有数中因数之和为偶数的数目 思路 第二次写这个题 首先想到唯一分解定理 \[ s=p_1^{n_1}*p_2^{n_2}...p_m^{n_m} \] \[ ans=\prod \sum p_i^j \] 其中ans为所有因子之和 明显的,若ans为偶数,则所有 $ \sum p_i^j \(为偶数 又\) \sum_{1 \to j} p_i^j $应为奇数…
链接: https://vjudge.net/problem/LightOJ-1336 题意: Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6…
题目大意:f(n)为n的因子和,给出 n 求 1~n 中f(n)为偶数的个数. 题目思路:算数基本定理: n=p1^e1*p2^e1 …… pn^en (p为素数): f(n)=(1+p1+p1^2+p^3……+p^e1)*(1+p2+p2^2……+p2^e2)……*(1+pn+pn^2……+pn^en). 偶数个个奇数相乘仍为奇数,奇数个奇数相乘则为偶数,为了使f(n)为奇数,那么多项式中的每一项都应为奇数. 对于每个多项式内:偶数个奇数相加为偶数,奇数个奇数相加为奇数,为了使多项式为奇数,那…
--->题意:给一个函数的定义,F(n)代表n的所有约数之和,并且给出了整数拆分公式以及F(n)的计算方法,对于一个给出的N让我们求1 - N之间有多少个数满足F(x)为偶数的情况,输出这个数. --->分析:来考虑F(x)为奇数的情况,给据题目中给我们的公式,,如果F(x)为奇数,那么这个多项式里面的任何一项都必须是奇数,可以知道p = 2时,        p^e - 1肯定是奇数,如果p != 2,当且仅当e为偶数的时候,此项为奇数,证明如下: 原式变形为[ p^(e+1) -p + (…
题干中给出函数公式: 其中pi为n的每个素因数,ei为其个数.设该函数为F(x),其意义为x的约数之和.问在1-n中有多少x,令F(x)为偶数. 分析:设f(p)为(p^(e+1)-1)/(p-1).若F(x)为奇数,则任意的f(pi)都为奇数. f(p)还可以写成:f(p)= (1+p^1+p^2+...+p^e).则当p==2时,f(p)肯定是奇数(偶数+1);当p!=2时,因为p是素数,所以p一定是奇数.则e偶数时,f(p)为奇数. 所以一个数x若可以表示为 (2^2k1)*(3^2k2)…
原题链接 基础数论中很经典的一道题 题意 给出了σ(n)的计算公式,让你找出整数1-n中有多少对应σ(n)的值是偶数. 思路 观察σ(n)的公式发现,每一个乘项都是 (piei+1 - 1) / (pi - 1) 这样,类比等比数列前n项和公式: (piei+1 - 1) / (pi - 1) = (1 - piei+1) / (1 - pi) = 1 + pi + pi2 + ... + piei 即 σ(n) = ∏(1 + pi + pi2 + ... + piei) 题目要找σ(n)是偶…
http://lightoj.com/volume_showproblem.php?problem=1336 Sigma Function Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1336 Description Sigma function is an interesting function in Number Theor…
1336 - Sigma Function   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all…
常用的化简方法(高中就常用了):     p^(e+1)-1/p-1=             [ p^(e+1) -p + (p-1) ]/ (p-1) = p*(p^e-1)/(p-1) + 1   (也可以直接分解p^e-1) 常用的思路:反面验证  比如本题,求偶数(试探后发现不太好求),则推出奇数条件 再看本题.要想让σ(n)为偶数,只要有一项为偶数即可, 化简变为,观察这个式子,pi都是素数,除2以外都是奇数,所以式子奇偶决定于ei,若ei为奇数,就相当于奇数个奇数(若pi不是2,那…
题目链接:https://vjudge.net/problem/LightOJ-1336 1336 - Sigma Function    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ).…
1336 - Sigma Function Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6+8+12+24=60. Sigma of smal…
Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For exam…
http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1341 Description It's said that Aladdin had to solve seven…
A - (例题)整数分解 Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Description Find the result of the following code: long long pairsFormLCM( int n ) {    long long res = 0;   …
http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. 思路:根据唯一分解定理,把X写成若干素数相乘的形式,则X的正因数的个数为:(1+a1)(1+a2)(1+a3)...(1+an).(ai为指数) 因为这道题目是求矩形,所以知道一个正因数后,另一个正因数也就确定了,所以每组正因数重复计算了两遍,需要除以2. 最后减去小于b的因数. #include<io…
题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222,最后暴力求出最短边长以内的因子,相减得出答案. 想要求出s以内的因子数量,就用到了唯一分解定理,先求素数想要求出s以内的因子数量,就用到了唯一分解定理,先求素数想要求出s以内的因子数量,就用到了唯一分解定理,先求素数 唯一分解定理: 任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有…
题意:求有多少对数对(i,j)满足lcm(i,j) = n,1<=i<=j, 1<=n<=1e14. 分析:根据整数的唯一分解定理,n可以分解为(p1^e1)*(p2^e2)*(p3^e3)*...*(pn^en).其中pi是每个不同的素因子. 同样可将 i 和 j 分解为(a1^c1)*(a2^c2)^(a3^c3)...(an^cn) 和 (b1^d1)*(b2^d2)*(b3^d3)*...(bn^dn). 因为lcm(i,j) = n.所以对任意 i,都有max(ci,di…
唯一分解定理 先分解面积,然后除2,再减去面积%长度==0的情况,注意毯子不能是正方形 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<…
题意:给出a,b,问有多少种长方形满足面积为a,最短边>=b? 首先简单讲一下唯一分解定理. 唯一分解定理:任何一个自然数N,都可以满足:,pi是质数. 且N的正因子个数为(1+a1)*(1+a2)*(1+a3)*.......*(1+an). 看了网络上很多人写的题解,普遍的做法是先找出N的所有正因子n,(n/2)就是在不考虑最短边>=b时所有存在的长方形,现在考虑最短边>=b,只需要减去所有能整除a且小于b的因子即可. 具体写法: 1.先预处理素数 2.用唯一分解定理求出N的所有因子…
Sigma Function Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1336 Description Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This fu…
http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. 什么叫唯一分解定理:算术基本定理可表述为:任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积N=P1a1P2a2P3a3......Pnan,这里P1<P2<P3......<Pn均为质数,其中指数ai是正整数.这样的分解称为 N 的标准分解式 我们求出n的因…
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=109329#problem/C   题目在文末 题意:1~n (n:1~1012)中,因子和为偶数的有几个.题解: 因子和 Sum=(p1^0+p1^1….p1^e1)*(p2^0+p2^1…p2^e2)……(pn^0+…pn^en); = (p1^0+p1^1….p1^e1),(p2^0+p2^1…p2^e2),……(pn^0+…pn^en)中只要有一个是偶数,因子和sum就为偶数.所…
Pairs Forming LCM Find the result of the following code: ; i <= n; i++ )        for( int j = i; j <= n; j++ )           if( lcm(i, j) == n ) res++; // lcm means least common multiple    return res;} A straight forward implementation of the code may…
Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4+6+8+12+24=60. Sigma of small numbers is easy to f…
题目描述 Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫 Hankson.现 在,刚刚放学回家的 Hankson 正在思考一个有趣的问题. 今天在课堂上,老师讲解了如何求两个正整数 c1 和 c2 的最大公约数和最小公倍数.现 在 Hankson 认为自己已经熟练地掌握了这些知识,他开始思考一个“求公约数”和“求公 倍数”之类问题的“逆问题”,这个问题是这样的:已知正整数 a0,a1,b0,b1,设某未知正整 数 x 满足: 1. x 和 a0 的最大公约…
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4053   Accepted: 1318 Description The binomial coefficient C(m,n) is defined as m! C(m,n) = -------- n!(m-n)! Given four natural numbers p, q…
uva10375 Choose and Divide(唯一分解定理) 题意: 已知C(m,n)=m! / (n!*(m-n!)),输入整数p,q,r,s(p>=q,r>=s,p,q,r,s<=10000), 计算C(p,q)/C(r,s).输出保证不超过10^8,保留5位小数. 分析: 本题时间上基本上没有太大的限制,可以暴力求解C(m,n); #include<cstdio> #include<cstring> #include<iostream>…
题意:求C(p,q)/C(r,s),4个数均小于10000,答案不大于10^8 思路:根据答案的范围猜测,不需要使用高精度.根据唯一分解定理,每一个数都可以分解成若干素数相乘.先求出10000以内的所有素数,用a数组表示唯一分解式中个素数的指数,求出每个分子部分的素因子,并且相应的素数的指数加一.分母则减一.最后求解唯一分解式的值. #include<stdio.h> #include<string.h> #include<math.h> ; int pr[N],p[N…
一行代表一个数 x 给你底数和指数 求x-1的唯一分解定理的底数和指数 从大到小输出 #include<stdio.h> #include<string.h> #include<algorithm> #include<vector> #include<math.h> using namespace std; #define MAXN 100010 double z[MAXN],x[MAXN]; bool pri[MAXN]; int p[MAXN…
题目链接 题意:输入两个整数L,U(L <= U <= 1000000000, u - l <= 10000),统计区间[L,U]的整数中哪一个的正约数最多,多个输出最小的那个 本来想着用欧拉函数,打个表求所有的约数个数,但是u太大,直接暴力求解 利用唯一分解定理,刷选出根号1000000000的素数,对l,u区间的每一个数进行分解 #include <iostream> #include <cstdio> #include <algorithm> #…