ICode9

精准搜索请尝试: 精确搜索
  • [洛谷P2567] SCOI2010 幸运数字2019-10-30 10:04:41

    问题描述 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是“幸运号码”!但是这种“幸运号码”总是太少了,比如在[1,100]的区间内就只有6个(6,8,66,68,86,88),于是他又定义了一种“近似幸运号码”。

  • UVa11889 - Benefit2019-10-19 18:02:47

    题意:给出A,C,找出最小的C使得lcm(A,B)=C 思路:lcm=(a*b)/gcd,把等号两侧同时除以a得到lcm/a=b/gcd左侧是已知的,右侧的gcd是a的因子中的一个,直接枚举a的所有因子找到答案就行了。 1 #include<math.h> 2 #include<stdio.h> 3 #include<algorithm> 4 5 6 using namespace std; 7 8

  • Java中数组中所有数字的LCM2019-10-12 11:03:54

    我有一个整数数组,我试图找到该数组中所有值的LCM(最小公倍数).我已经单独编写了一个lcm方法;它接受两个值作为输入,并返回lcm.我的lcm方法工作得很好,但是当我用它来查找所有值的LCM时,我得到了错误的答案. 这是我的gcd和lcm方法: public static int gcd(int a, int b){ if (a<

  • Codeforces 12202019-10-03 13:02:03

    C 水题 Code #include<bits/stdc++.h> using namespace std; const int maxn=500003; char s[maxn]; int n; int main(){ scanf("%s",s+1); n=strlen(s+1); for(int i=1,mi=maxn;i<=n;i++){ mi=min(mi,int(s[i])); puts(mi<s

  • c – 计算模数为1000000007的N个数的LCM2019-10-03 07:05:45

    我正在解决LCM上的以下问题:计算模数为1000000007的N个数的LCM 我的方法: typedef unsigned long long ull; const ull mod=1000000007; ull A[10009]; /*Euclidean GCD*/ ull gcd(ull a,ull b) { while( b != 0) { ull t = b; b= a %t; a = t;

  • GCD and LCM HDU 4497 数论2019-09-08 10:58:05

    GCD and LCM HDU 4497 数论 题意 给你三个数x,y,z的最大公约数G和最小公倍数L,问你三个数字一共有几种可能。注意123和321算两种情况。 解题思路 L代表LCM,G代表GCD。 \[ x=(p_1^{i_1})*(p_2^{i_2})*(p_3^{i_3})\dots \] \[ y=(p_1^{j_1})*(p_2^{j_2})*(p_3^{j_3})\dots \] \[ z=(p_

  • LightOJ 1289 LCM from 1 to n(位图标记+素数筛2019-09-07 12:02:10

    https://vjudge.net/contest/324284#problem/B 数学水题,其实就是想写下位图。。和状压很像 题意:给n让求lcm(1,2,3,...,n),n<=1e8 思路:显然ans = 所有小于n的素数p[i]的max(p[i]^k)相乘。由于空间太大,装素数的数组开不下,要用位图,int可以保存32位二进制,我们可以把每一位当作一个数,又

  • [hdu5584]LCM Walk2019-09-04 10:41:25

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description A frog has just learned some number theory, and can’t wait to show his ability to his girlfriend. Now the frog is sitting on a grid map of infinite ro

  • 题解 P4161 【[SCOI2009]游戏】2019-09-03 22:53:49

    先无良宣传一下博客 \(wwwwww\) 文章列表 - 地灵殿 - 洛谷博客 知识点: 问题转化 , 背包DP 原题面: P4161 [SCOI2009]游戏 对于1到N这N个数字,都有唯一且不同的1到N的数字与之对应。 最开始 把数字按顺序1,2,3,……,N写一排在纸上。 然后再在这一排下面写上它们对应的数字。

  • CodeForces 55D2019-08-30 23:02:03

    题意略。 思路: 本题可以说是醉翁之意不在酒了。要解开本题有几个关键点: 1.意识到数X = An An-1 An-2 An-3 .... A2 A1能被{An,An-1,An-2,....,A1}这n个数整除的充要条件是lcm(An,An-1,An-2,....,A1) | X。 2.要知道1~9这9个数进行组合最大的lcm是2520,而且组合出的lcm个数有限,最多4

  • java – 从1到100的所有数字均可被整除的最小正数是多少?2019-08-28 22:12:37

    以下是我的代码,我尝试使用BigInteger inn Java计算从1到100的所有数字的LCM.但它没有提供任何答案. import java.math.BigInteger; public class CommonOneToHundred { public static void main(String[] args) { // TODO Auto-generated method stub BigI

  • GCD + LCM + 素数打表 + 快速幂2019-08-22 10:37:33

    1 gcd为两个数的最大公因数 gcd模板 int gcd (a , b ) { return b ? gcd (b , a % b ) : a ; } 2 lcm为两个数的最小公倍数 lcm(a,b)=(a*b)/gcd(a,b) 3 素数打表 //求0~100000以内的素数 //(下标为0的是素数,下标不为0的为合数) bool str[100010]; void prime() { str[1]=1

  • P1829 [国家集训队]Crash的数字表格 / JZPTAB2019-08-18 21:02:30

    DescriptionDescriptionDescription 求 ∑i=1n∑j=1mlcm(i,j)\huge \sum_{i=1}^n\sum_{j=1}^m lcm(i,j)i=1∑n​j=1∑m​lcm(i,j) 数据范围:n,m≤107n,m\leq 10^7n,m≤107 有模数 SolutionSolutionSolution 其实可以用这道题的优化版本预处理f(x)=∑j=1xlcm(j,x)f(x)=\sum_

  • B2019-08-14 11:06:28

    题意: 给你一个集合M,里面最多有10个非负数,问1~n-1中一共有多少个数可以被其中一个整除。 题解:容斥定理,这个题和C题几乎一样,我们只要在C的基础上求个LCM就行了 代码: #include<bits/stdc++.h> using namespace std; #define ll long long ll gcd(ll a,ll b) { return b==0?a:g

  • shell脚本[] [[]] -n -z 的含义解析2019-08-12 14:39:08

    原文链接:https://blog.csdn.net/keep_lcm/article/details/80551435 https://blog.csdn.net/keep_lcm/article/details/80551435 参考一下

  • 【数论】GCD与LCM2019-08-11 21:04:38

    目录 gcd的欧几里得算法 gcd的二进制算法 最小公倍数lcm gcd的欧几里得算法 又称辗转相除法,是一个求解两数最大公因数的算法。算法可以用递推式 \(gcd(a,b)=gcd(b, {a}\mod{b})\) 概括,边界条件是 \(gcd(a,0)=a\)。代码如下(相信每个OIer都会): int gcd(int a,int b){ //递归形

  • 洛谷 UVA11388 GCD LCM2019-08-10 20:55:09

    UVA11388 GCD LCM Description of the title PDF The GCD of two positive integers is the largest integer that divides both the integers without any remainder. The LCM of two positive integers is the smallest positive integer that is divisible by both the int

  • 洛谷 P5150 生日礼物 题解2019-08-08 12:01:47

    题面 因为 n=lcm(a,b)n = lcm(a, b)n=lcm(a,b) ,可以得出: a  和 b  的质因数都是 n 的质因数 对于 n  的每个质因数 x ,在 n 中的次数为 y ,那么 x  在 a 和 b  中至少有一个次数为 y,在另一个中的次数 <=y。 所以我们只要把 n 的每个质因数的次数求出来就好了 即ans=(2a1+1)×

  • [欧拉函数] Bzoj P2226 LCMSum2019-08-08 11:55:53

    Description Given n, calculate the sum LCM(1,n) + LCM(2,n) + .. + LCM(n,n), where LCM(i,n) denotes the Least Common Multiple of the integers i and n.   题解   代码 1 #include <cstdio> 2 #include <iostream> 3 #define N 1000010 4 #define ll long

  • 物不知其数2019-07-30 15:01:16

    文章分为三个大的部分: 大标题1是物不知其数问题的引入,大标题2将问题抽象。 大标题3、4、5是物不知其数问题的三种解法及其代码实现。 大标题6是提出的一些问题及不太完善的解释。 提醒: 看文章最好先掌握文章整体结构,电脑会比较方便,可以点击标题跳到自己想看的部分。 看代码发现看不

  • 洛咕 【P1891】疯狂LCM & 三倍经验2019-07-30 09:53:50

    经验给掉先: 经验*1 经验*2 经验*3 这里给个跑得比较慢的 \(n \sqrt n\) 预处理然后 \(O(1)\) 回答询问的做法 式子 首先我们推柿子: \[\begin{aligned}ANS&= \sum_{i=1}^n lcm(i,n)\\ &=\sum_{i=1}^n {i* n\over (i,n)} \\&= n\sum_{i=1}^n {i\over (i,n)} \\&=n\sum_{d|n} \sum_{

  • Codeforces B. Minimum Possible LCM2019-07-28 20:03:22

    题目描述: B. Minimum Possible LCM time limit per test 4 seconds memory limit per test 1024 megabytes input standard input output standard output You are given an array aconsisting of integers a1,a2,…,*a**n* Your problem is to find such pair of indices i,j tha

  • [Comet OJ - Contest #7] 签到题2019-07-15 15:42:58

    签到题(在我看来,是道送命题) 已经提交 已经通过 时间限制:1000ms 内存限制:256MB 82.60% 提交人数:569 通过人数:470 题目描述   多次询问,每次询问给一个值域范围 [l,r][l,r],要回答下列四个问题: 从这个范围内选出两个整数(两个数可相同), (1) 这两个数的最小公倍数最大是多少? (2

  • gcd和lcm2019-07-07 09:02:39

    \(GCD\)(辣鸡欧几里得) 直接记住就好了 ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } 有一个用异或久解决的,忘记了,暂时不理了 \(EXGCD\) 求\(ax+by=gcd(a,b)=d\)的一组最小解 int exgcd(int a,int b,int &x,int &y) { if(b==0) { x=1; y=0;

  • P1072 Hankson 的趣味题2019-06-13 16:50:31

    原题链接  https://www.luogu.org/problemnew/show/P1072 这个题是数论+暴力吧,需要一些优化。 先来看看怎么求最大公约数和最小公倍数: 欧几里德算法 ------求最大公约数 概述 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。其计算原理依赖于下面的定理: gcd

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有