当前位置: 首页 > wzjs >正文

wordpress设置网站导航wordpress建m域名网站

wordpress设置网站导航,wordpress建m域名网站,免费论坛申请网站,攻击jsp网站数论 欧拉函数X质数(线性筛与二进制枚举)求解组合数欧拉降幂(乘积幂次)乘法逆元最小质因子之和模版 欧拉函数 欧拉函数的定义就是小于等于n的数里有f(n)个数与n互质,下面是求欧拉函数的模版。 package com.js.datas…

数论

  • 欧拉函数
  • X质数(线性筛与二进制枚举)
  • 求解组合数
  • 欧拉降幂(乘积幂次)
  • 乘法逆元
  • 最小质因子之和
  • 模版

欧拉函数

欧拉函数的定义就是小于等于n的数里有f(n)个数与n互质,下面是求欧拉函数的模版。
在这里插入图片描述

package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.Scanner;public class 欧拉函数模版 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();for (int i = 0; i < n; i++) {int x = scanner.nextInt();System.out.println(oula(x));}}static int oula(int x){int res = x;for (int i = 2; i <= x / i; i++) {if (x % i == 0) {res = res / i * (i - 1);while (x % i == 0) {x /= i;}}}if(x > 1){res = res / x * (x-1);}return res;}
}

X质数(线性筛与二进制枚举)

在这里插入图片描述

package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.ArrayList;public class X质数 {public static void main(String[] args) {//线性筛把质数筛出来int[] minp = new int[1000001];ArrayList<Integer> prime = new ArrayList<>();boolean[] isp = new boolean[1000001];for (int i = 2; i <= 1000000; i++) {if(minp[i] == 0){prime.add(i);}for (int pp : prime){if(pp * i > 1000000){break;}minp[i * pp] = pp;if(minp[i] == pp){break;}}}for (int pp : prime){isp[pp] = true;}int ans = 0;//二进制遍历判断是否为质数for (int i = 1; i < 1000001; i++) {String s = i + "";int ls = s.length();for (int j = 1; j < Math.pow(2,ls); j++) {String er = Integer.toBinaryString(j);int ler = er.length();String dudu = "";for (int k = ler - 1; k >= 0; k--) {if(er.charAt(k) == '1'){dudu = s.charAt(k + ls -ler) + dudu;}}int now = Integer.parseInt(dudu);if(isp[now]){ans++;break;}}}System.out.println(ans);}
}

求解组合数

在这里插入图片描述

package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.Scanner;public class 求解组合数 {static int mod = 1000000007;static long[] ni;static long[] jie;public static void main(String[] args) {Scanner scanner = new Scanner(System.in);//求阶乘jie = new long[10000001];jie[0] = 1;for (int i = 1; i < 10000001; i++) {jie[i] = (jie[i-1] * i) % mod;}//求逆元ni = new long[10000001];ni[0] = 1;for (int i = 1; i < 10000001; i++) {ni[i] = niyuan(jie[i]);}int q = scanner.nextInt();for (int i = 0; i < q; i++) {int n = scanner.nextInt();int m = scanner.nextInt();System.out.println((((jie[n] * ni[m]) % mod) * ni[n-m]) % mod);}}//快速乘法幂求逆元static long niyuan(long x){long res = 1;int y = mod - 2;while (y > 0){if((y & 1) == 1){res = (res * x) % mod;}y>>= 1;x = (x * x) % mod;}return res;}
}

欧拉降幂(乘积幂次)

在这里插入图片描述

package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.Scanner;public class 乘积幂次_欧拉降幂 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int m = scanner.nextInt();int mod = 1000000007;//求幂次long fm = 1;for (int i = 1; i <= m; i++) {fm = (fm * i) % (mod - 1);}//快速乘法幂long en = 1;int x = n;long y = fm;while (y > 0){if((y & 1) == 1){en = (en * x) % mod;}y >>= 1;x = (x * x) % mod;}System.out.println(en);}
}

乘法逆元

在这里插入图片描述

//package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int t = scanner.nextInt();int mod = 1000000007;for (int i = 0; i < t; i++) {int n = scanner.nextInt();long x = n;int y = mod - 2;long res = 1;//快速乘法幂while (y > 0){if((y & 1) == 1){res = (res * x) % mod;}y >>= 1;x = (x * x) % mod;}System.out.println(res);}}
}

最小质因子之和

在这里插入图片描述

模版

package com.js.datastructure.recursion.蓝桥.总结.数论;import java.util.ArrayList;
import java.util.Scanner;public class 最小质因子之和 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int[] minp = new int[20000001];ArrayList<Integer> Prime = new ArrayList<>();for (int i = 2; i < 20000001; i++) {if(minp[i] == 0){Prime.add(i);minp[i] = i;}for (int pp : Prime){if(pp * i > 20000000){break;}minp[pp*i] = pp;if(minp[i] == pp){break;}}}//求前缀和for (int i = 2; i < 20000001; i++) {minp[i] = minp[i-1] + minp[i];}int t = scanner.nextInt();for (int i = 0; i < t; i++) {int n = scanner.nextInt();System.out.println(minp[n]);}}
}
package com.js.datastructure.recursion.蓝桥.国特训练营.数论;import java.util.ArrayList;public class 模版 {static ArrayList<Integer> prime;static int[] minp;public static void main(String[] args) {}//快速乘法幂//有取余的时候都取余static long fast(int x, int y){long res = 1;while (y > 0){if((y & 1) == 1){res = res * x;}y>>=1;x = x * x;}return res;}//线性筛static void shai(){for (int i = 2; i < minp.length; i++) {if(minp[i] == 0){prime.add(i);minp[i] = i;}for (int pp : prime){if(pp * i >= minp.length){break;}minp[pp*i] = pp;if(minp[i] == pp){break;}}}}//欧拉函数:就是小于这个数和他互质数的个数,质数为n-1static int oula(int x){int res = x;for (int i = 2; i <= x / i; i++) {if(x % i == 0){res = res / i * (i-1);while (x % i == 0){x/=i;}}}if(x > 1){res = res / x * (x-1);}return res;}//求逆元//模数为质数是,逆元为a^m-2 % m ,用快速乘法幂//大组合数
}

文章转载自:

http://EDQRX6wy.wtxdp.cn
http://74BRtYsB.wtxdp.cn
http://dUIz92hW.wtxdp.cn
http://VjmkeNsq.wtxdp.cn
http://S4nuNt0F.wtxdp.cn
http://AGOdP99P.wtxdp.cn
http://gcyKmcJl.wtxdp.cn
http://SGKX7RHT.wtxdp.cn
http://wD3HxvUi.wtxdp.cn
http://VwbsLfCO.wtxdp.cn
http://QMCFX94h.wtxdp.cn
http://RxZcpiyR.wtxdp.cn
http://PIbjHA6V.wtxdp.cn
http://8g6g836s.wtxdp.cn
http://Y0FY77mR.wtxdp.cn
http://70U8JrkW.wtxdp.cn
http://0RLPmS8A.wtxdp.cn
http://jvvWREfq.wtxdp.cn
http://6W4UD6qo.wtxdp.cn
http://nCxJcv7w.wtxdp.cn
http://TA75QwFm.wtxdp.cn
http://oMlsdLMK.wtxdp.cn
http://FcKCsIu0.wtxdp.cn
http://0bO4JfJH.wtxdp.cn
http://iV2f0lzg.wtxdp.cn
http://Txsfio9j.wtxdp.cn
http://exx5HS4P.wtxdp.cn
http://3GyaxKt3.wtxdp.cn
http://HUxTC8SB.wtxdp.cn
http://CPCgxMnU.wtxdp.cn
http://www.dtcms.com/wzjs/620764.html

相关文章:

  • 做壁纸网站好免费优化
  • 什么公司网站建设比较好360怎么做网站
  • 网站设计公司 国际高级网页设计师证书
  • 山东省建设厅注册中心网站开发公司交的农民工工资保证金可以退还吗
  • 中太建设集团股份有限公司网站a3网站建设
  • 网站图片怎么替换网站跳出的广告是怎么做的
  • wordpress the_衡水网站排名优化公司
  • 精仿腾讯3366小游戏门户网站源码织梦最新内核带全部数据!男男床做视频网站在线
  • 有什么可以下载软件的网站软件开发和网站建设哪个好
  • 电子商务网站建设实训报告文章网站建设 问卷调查
  • 如何自己做外贸网站研发流程的六个阶段
  • 网站建设费用 多少物流企业网站模板下载
  • 团购网站建设报价免费个人网站空间申请
  • 网站排名掉了怎么恢复公司被其它人拿来做网站
  • 规划网站的总结河北智能网站建设平台
  • 东莞做网站公司首选!网站建设子目录
  • 的品质网站建设php图书管理系统
  • 15年做那个网站致富烟台企业展厅设计
  • php开发网站建设湖南智慧团建登录入口网址
  • angular 做网站阿里云企业邮箱怎么申请
  • 有创意的个人网站自己电脑做网站模板
  • 北京快速网站建设python做爬虫和做网站
  • 如何做网站开屏建设银行园区公积金管理中心网站
  • 色盲悖论衡水搜索引擎优化
  • 网站如何做问卷调查公众微信绑定网站帐号
  • 网站建设方面手机版网站的优势
  • 赵朴初网站建设微信视频号怎么引流推广
  • 青岛网站模板ip反查工具网站
  • 口碑好网站建设在哪里有没有专做烘焙的网站
  • 兰州网站优化推广湖北建设厅