![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
浪流人
这个作者很懒,什么都没留下…
展开
-
Leading and Trailing 快速幂
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the numbe...原创 2020-04-06 21:35:45 · 95 阅读 · 0 评论 -
唯一分解定理
任何一个大于1的自然数 N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积 N=P1a1 P2a2P3a3…Pnan,这里P1<P2<P3…<Pn均为质数,其中指数ai是正整数。这样的分解称为 N 的标准分解式.应用是n的因子个数 = (1+a1)(1+a2)…(1+an)样例: 1000=2* 500=2* (2 * 250)=2 * 2 *( 2 * 125)=2 * 2 * 2 *(5 * 25)=2 * 2 * 2 * 5 * 5 *5=23*53Alad原创 2021-03-26 21:35:29 · 332 阅读 · 0 评论 -
尺取法
Subsequence POJ - 3061题意 给定n和s 求n个数中满足大于等于s的最小长度#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>using namespace std;#define inf 0x3f3f3ftypedef long long ll;const int N=10000原创 2021-03-26 19:58:12 · 71 阅读 · 0 评论 -
求组合数
凡是对大数取余的 一般都是用卢卡斯逆元#include <iostream>#include<stdio.h>using namespace std;const int p=1e9+7;typedef long long ll;ll qmi(ll a,ll k)//用到快速幂/逆元/组合公式{ ll res=1; while(k) { if(k&1) res=res*a%p; a=原创 2021-01-24 16:41:44 · 90 阅读 · 1 评论 -
Harmonic Number (II) LightOJ - 1245
求f(n)=n/1+n/2…n/n,其中n/i保留整数f(n)这个函数刚好关于y=x对称,对称点位sqrt(n);所以ans2-nn就可以求出来了#include<stdio.h>#include<cmath>#include<algorithm>#include<iostream>#include<string.h>using namespace std;typedef long long ll;int main(){原创 2020-10-05 18:31:28 · 98 阅读 · 0 评论 -
Leading and Trailing LightOJ - 1282
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk.InputInput starts with an integer T (≤ 1000), denoting the number of test cases.Each case starts with a line containing原创 2020-10-04 08:41:58 · 111 阅读 · 0 评论 -
第四周下 数论
先分析下直线分割平面的情况,增加第n条直线的时候,跟之前的直线最多有n-1个交点,此时分出的部分多出的平面为(n-1)+1;折线也是同理,f(1)=2,f(2)=7,先画好前面n-1条折线,当增加第n条折线时,也就是增加了2n条和2n-1条他们连在了一起,他们各增加了2n,2(n-1)个交点,因为连在了一起,所以此时与图形新的交点为22(n-1)+1 所以推出f(n)=f(n-1)+4(n-1)+1,n>=3递推#include<stdio.h>#include<string.原创 2020-09-28 09:47:21 · 139 阅读 · 0 评论