网站首页 站内搜索

搜索结果

查询Tags标签: GCD,共有 190条记录
  • The Luckiest number HDU - 2462

    原题链接 考察:欧拉定理 思路: 已知每个8888...888都可以被表示成: \[nums = \frac {8\times(10^x-1)}{9} \]\[nums \equiv 0 \pmod L \]\[(10^x-1)\% \frac{9\times L}{gcd(8,L)}==0 \]  根据欧拉定理,若10与\(\frac{9\times L}{gcd(8,L)}\)互质,则存在最小的正整数x,使…

    2021/6/3 10:51:16 人评论 次浏览
  • Python最大公约数和最小公倍数计算

    从键盘接收两个整数,编写程序求出这两个整数的最大公约数和最小公倍数 a,b=eval(input()) def gcd(m,n):if m>n:return gcd(n,m-n)elif n>m:return gcd(m,n-m)else:return m c = gcd(a,b) d = a*b/c print("{}和{}的最大公约数为{},最小公倍数为{}".form…

    2021/5/30 20:51:42 人评论 次浏览
  • 【UVA12716】 GCD等于XOR

    GCD等于XOR题目描述输入格式输出格式题意翻译 输入数据组数t,接下来t行每行给定一个数字n,如样例所示格式输出满足1<=b<=a<=n且gcd(a,b)==a xor b的(a,b)二元组个数。 输入样例 2 7 20000000输出样例 Case 1: 4 Case 2: 34866117题意分析 这道题很良心,题目即…

    2021/5/22 10:28:11 人评论 次浏览
  • 算法设计与分析第四章作业

    算法设计与分析第四章作业 (1)求2+22+222+2222+…+22…22(不考虑精度)#include <iostream> typedef long long LL; using namespace std; //快速幂 LL FastPower(LL m,LL n){if(n==0) return 1;LL res=FastPower(m,n>>1);if(n&1) return res*res*m;//奇数…

    2021/5/20 22:54:42 人评论 次浏览
  • Baby-step Giant-step and its extension

    from wikipediaIn group theory, a branch of mathematics, the baby-step giant-step is a meet-in-the-middle algorithm for computing the discrete logarithm or order of an element in a finite abelian group due to Daniel Shanks. The discrete log problem is …

    2021/5/19 10:29:33 人评论 次浏览
  • ACM数论部分学习(持续更新)

    数论部分 自bilibili n多视频 https://www.bilibili.com/video/BV1Zf4y1r7qE?from=search&seid=9993155426548406857 以及https://oi-wiki.org/ 学习 模运算 模运算 常用于结果对某数取模 (a+b)mod m = ((a mod m)+(b mod m)) mod m; (a-b)mod m = ((a mod m)-(b…

    2021/5/19 10:26:30 人评论 次浏览
  • 浅谈扩展欧几里得算法

    什么是拓展欧几里得?简单的说,就是求关于x,y的方程 ax + by = gcd(a,b) 的所有整数解现在我们来解决一下三个问题 怎么求上述方程的特解?怎么求由特解推出其他的所有解?如何求的是ax + by = c,则解为什么?一、求特解 我们都知道,欧几里得公式可以由这个式子表达 gc…

    2021/5/18 22:28:49 人评论 次浏览
  • 【Mac OS开发】使用gcd快速排序数组,使用gcd多线程查找数组中的最大值

    此示例的功能:使用gcd排序一个有4万数字的数组,数组中的数字都是随机生成的 生成数组代码如下_numsMutableArray = [[NSMutableArray alloc] init];for (int i = 0; i < 40000; i++) {NSNumber *temp = [NSNumber numberWithInt:arc4random_uniform(1000000)];[_nums…

    2021/5/13 10:29:14 人评论 次浏览
  • 第十二届蓝桥杯最短路径(动态规划法)

    #include<iostream> using namespace std; //辗转相除法(递归)求最大公约数 int gcd(int a, int b) {return b == 0 ? a : gcd(b,a%b);} //求最小公倍数 int lcm(int a, int b){return a*b/gcd(a,b);} int main() {//动态规划开辟数组 int dp[3000] = {0};//求出…

    2021/5/8 10:25:47 人评论 次浏览
  • 问题 A: C语言:函数1(最大公约数)

    题目描述 输入两个正整数m和n(1<m, n<1000000000),求其最大公约数和最小公倍数。 输入 有多行,每行2个正整数m和n。 输出 m和n的最大公约数、最小公倍数。 样例输入 Copy 16 24 5 7 样例输出 Copy 8 48 1 35 提示 要求:编写求最大公约数和最小公倍数的函数。 #…

    2021/5/4 10:25:13 人评论 次浏览
  • CF914D 题解

    Luogu-CF914D 解题思路 对于操作 \(1\),关键是如何查找 \([l,r]\) 中不能整除 \(x\) 的个数。 可以想到用线段树暴力优化求解: 用线段树维护区间 \(\gcd\),如果一段区间的 \(\gcd\) 都能整除 \(x\),那么这段区间的所有数也都能整除 \(x\),那么我们可以利用这个特点,…

    2021/5/3 10:25:28 人评论 次浏览
  • 黑妹的游戏I-裴蜀定理

    https://ac.nowcoder.com/acm/problem/16766 大意:给出3个数a,b,c,每次任取两个数作减法,得到的数如果不存在,则加入,然后继续执行操作。 思路:得到的数一定是,那么要方程有解,ans就一定是gcd(a,b,c)的倍数,并且ans要小于max(a,b,c). //a*x+b*y+c*z = gcd(a,b,…

    2021/5/2 10:57:33 人评论 次浏览
  • 算法学习(4):gcd和exgcd

    GCD inline int gcd(int a,int b) { return b == 0 ? a : gcd(b,a % b); }EXGCD第一种int exgcd(int a, int b, int &x, int &y) {if (b == 0){x = 1;y = 0;return a;}int d = exgcd(b, a % b, x, y), x0 = x, y0 = y;x = y0;y = x0 - (a / b) * y0;return d; }第…

    2021/4/30 20:27:11 人评论 次浏览
  • 欧几里得算法

    欧几里得算法求最大公因数 package com.ttttttt; /*** m,n为两个数,gcd方法为求最大公因数*/ public class Gcd {public static long gcd(int m, int n){while (n!=0){int rem=m%n;m=n;n=rem;}return m;}public static void main(String[] args) {System.out.println(gcd…

    2021/4/30 1:27:13 人评论 次浏览
  • 2019蓝桥杯C++B等差数列

    #include <iostream> #include<vector> #include <set>using namespace std; int N; multiset<int>input; set<int> d; int zero=0;; int gcd(int i,int j) {if(i>j)swap(i,j);int temp=0;while(i!=0){temp=i;i=j%i;j=temp;}return temp…

    2021/4/17 12:55:23 人评论 次浏览
扫一扫关注最新编程教程