
数论
无
嘴角上扬*
渴求力量的家伙毫无疑问地都在追求着战斗!-更木剑八
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
求组合数预处理的两种方法
第一种方法 针对a b 数据量较小,直接处理a b的组合数方案 AcWing 885. 求组合数 I #include<iostream> using namespace std; const int N = 2020, mod = 1e9 + 7; int c[N][N];//相当于数学中的组合公式Cab(数学公式不知如何插入le...) void init(){ for(int i = 0; i < N; i++) for(int j = 0; j <=原创 2022-03-08 20:36:06 · 518 阅读 · 0 评论 -
1223.最大比例(蓝桥杯)
代码 #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const int N = 110; ll a[N], fz[N],fm[N]; ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } //这里之所以弃用辗转相除法的原因,是因为虽然更相减损术效率原创 2022-02-12 20:26:43 · 498 阅读 · 0 评论 -
Acwing2058. 笨拙的手指
#include<iostream> #include<algorithm> #include<cstring> #include<unordered_set> using namespace std; //unordered_set中函数insert count的使用 //秦九韶算法将b进制的str返回为十进制数字 int get(string a, int b)//将string类型的b进制数字转换为十进制数字 { int res = 0;原创 2022-01-29 12:55:51 · 697 阅读 · 0 评论 -
筛法求N之内的素数和求最大公约数
题目描述 用筛法求之N内的素数。 输入 N 输出 0~N的素数 样例输入 100 样例输出 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 代码 #include<iostream> using namespace std; int main() { int n; cin>>n; int a[n+1]; for(int i=1;i<=n;i++) a[i]=i;//存原创 2021-03-23 11:28:14 · 300 阅读 · 0 评论 -
数论:求一个数的因子专题(因子数,因子和,质因子)
问题1-求n的因子数、因子和 输入一个正整数N,求出这个数字存在多少个因子,以及因子之和。 分析 既要求因子数,又要求因子和,因此我们要从1开始遍历一直到根号n,如果n%i==0,因子数要+2,因为因子和+i和+n/i,另外由于精度问题,还需要对根号n的情况进行特判 代码 int cnt=0,long long sum=0; //cnt为因子数 sum为因子和 因子和可能很大,开long long void fun(int n) { if(n==1) cnt=1,sum=1; else原创 2021-04-21 22:37:56 · 3351 阅读 · 0 评论 -
HDU4608
题目大意 求一个正整数x满足两个条件 1、Y>X 2、各个位置数字之和%10等于0。 思路: 大数加法 要满足的是两个条件 1、Y>X 那么我们让x累加 在比x大的数字中搜索答案 2、各个位置数字之和%10等于0, 对于小于19的正整数 大于它且各个位数字之和%10=0 的最小的数就是19,大于19的就每次加一去判断,满足条件就跳出循环。 AC代码 #include<stdio.h> #include<string.h> using namespace std;转载 2021-06-04 00:29:08 · 103 阅读 · 0 评论 -
CodeForces 76E
E. Points time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given N points on a plane. Write a program which will find the sum of squares of distances between all pairs of points. Input The原创 2021-06-03 23:16:41 · 155 阅读 · 0 评论