随笔分类 -  数论:数论函数

摘要:【最大公约数】 1 ll qpow(ll a, ll x) 2 { 3 ll ret = 1; 4 while (x) 5 { 6 if (x & 1) 7 { 8 ret = (ret * a) % mod; 9 } 10 a = (a * a) % mod; 11 x >>= 1; 12 } 1 阅读全文
posted @ 2020-05-13 23:43 rentu 阅读(213) 评论(0) 推荐(0)
摘要:【来源】 https://blog.csdn.net/Clove_unique/article/details/50740412 【解决问题】 给定a,b,p,求最小的非负整数x,满足a^x≡b(modp) 【方法】 【讨论】 阅读全文
posted @ 2019-08-10 14:07 rentu 阅读(179) 评论(0) 推荐(0)
摘要:【HAOI2011】 Problem b 题目描述 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数。 输入格式 第一行一个整数n,接下来n行每行五个整数,分别表示a、b、c、d、k 输出格式 共n行, 阅读全文
posted @ 2019-07-27 19:11 rentu 阅读(133) 评论(0) 推荐(0)
摘要:【spoj 】LCMSUM Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n 阅读全文
posted @ 2019-07-27 19:00 rentu 阅读(337) 评论(0) 推荐(0)
摘要:【前置知识】 【数论分块】 【问题描述】求令i从1到n,i整除k的和 【解决方法】显而易见的,1~n的某个区间内,i整除k的值是相同的,所以我们只需要找到这个区间,然后用区间个数乘以这个区间的贡献(即i整除k的值) 1 int res=0; 2 for(int d=1;d<=nn;) { 3 int 阅读全文
posted @ 2019-07-25 09:23 rentu 阅读(257) 评论(0) 推荐(0)