数论
123
勇敢nn
用心去打造每一份美好
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
计算几何与图形
#include<iostream> #include<cmath> using namespace std; double pi = 3.1415926; double ares(double n, double x) { return (n * x * x * sin(2 * pi / n)) / (4 * (1 - cos(2 * pi / n)));//多边形面积公式 } int main() { int t; cin >> t;..原创 2022-05-03 19:38:18 · 353 阅读 · 0 评论 -
C++实现行列式的计算
1.沙路法求二三阶行列式 #include<iostream> using namespace std; const int N=1000; int arr[N][2*N]; int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { scanf("%d",&arr[i][j]原创 2021-10-01 11:09:16 · 1993 阅读 · 0 评论 -
博弈论..
1.Nim游戏 题目描述: 给定 n 堆石子,两位玩家轮流操作,每次操作可以从任意一堆石子中拿走任意数量的石子(可以拿完,但不能不拿),最后无法进行操作的人视为失败。问如果两人都采用最优策略,先手是否必胜。 测试样例: 输入: 2 2 3 输出: Yes 代码如下: #include <iostream> using namespace std; const int N = 100010; int main() { int n; scanf("%d", &n);原创 2021-08-27 20:32:24 · 193 阅读 · 0 评论 -
数论算法总结
1.欧拉函数 题目描述: 给定 n 个正整数 ai,请你求出每个数的欧拉函数。 测试样例: 输入: 3 3 6 8 输出: 2 2 4 欧拉函数的定义: 1∼N 中与 N 互质的数的个数被称为欧拉函数,记为 ϕ(N)。 代码如下: #include<iostream> using namespace std; int main() { int n; scanf("%d",&n); while(n--) { int a;原创 2021-08-22 20:27:54 · 202 阅读 · 0 评论 -
质数与约数
1.判断质数(试除法) //判断从2到n的质数并将其打印 #include<iostream> using namespace std; int main() { int n,flag=1; scanf("%d",&n); for(int i=2; i<=n; i++) { flag=1; for(int k=2; k<=i/k; k++) { if(i%k==0)原创 2021-08-05 11:58:05 · 198 阅读 · 0 评论 -
快速幂与组合数
#include<iostream> using namespace std; const int N=2010,mod=1e9+7; int c[N][N]; void init() { for(int i=0; i<N; i++) { for(int j=0; j<=i; j++) { if(!j) c[i][j]=1; else原创 2021-08-10 15:31:33 · 381 阅读 · 0 评论 -
思维与模拟
输入样例: 【样例1】 3 2 6 6 【样例2】 15 546 3192 1932 630 2100 4116 3906 3234 1302 1806 3528 3780 252 1008 588 输出样例: 【样例1】 2 【样例2】 42 题目描述: 如样例所示,给出一串数字,找出其中的最大值A和最小值a,将A=A-a,重复以上操作,直到数列中所有的数都相等。 代码如下: #include <bits/stdc++.h> using namespace std; int a[10000原创 2021-07-26 19:43:36 · 187 阅读 · 0 评论
分享