ICode9

精准搜索请尝试: 精确搜索
  • 2019年东北四省赛感想2019-06-07 10:01:42

      打完东北四省赛之后一直都没空,然后到了放假的时候才有空闲下来,写了这篇感想。     今年的东北四省赛的地点在吉林省的吉林市 ,在东北电力大学,不得不说东北电力大学的伙食还可以,量很足。今年东北四省赛的出题人是杭电的大佬,出了一堆数据不好处理的题,今年的题,比去年的题还要难

  • 关于一些数论问题例题的讨论2019-05-31 13:50:50

      大概就是写一些数论水题的题解?   一.[AHOI2005]约数研究 洛谷oj P1403   可能需要事先学习的算法:     埃氏筛法(素数筛)   题意很容易理解。很明显这是一道真正的水题,适合初学者理解筛法的思想。   30分暴力做法:     对于一个数$i(i∈[1,n])$ ,枚举所有$[1,i)$之间

  • “玲珑杯” 线上赛Round #17 B 震惊,99%+的中国人都会算错的问题2019-05-04 20:42:40

    传送门 __debug神仙计数课件凑系数入门题,我又被锤了。 我们先不考虑奇数的限制,想一下怎么做。是不是可以将任意子集的lcm进行容斥,算是比较简单的容斥了。 然后我们思考一下,如何通过凑系数来满足奇数的限制。 打表/画韦恩图可知系数为\((-2)^{n-1}\),暂时还不会推系数的方法,先坑着。

  • Codeforces Round #554 (Div. 2) C. Neko does Maths2019-05-04 11:50:54

    链接:https://codeforces.com/contest/1152/problem/C 题意:给两个数a和b,找到一个最小的k,使得a+k和b+k的lcm最小 题解:假设a>b,gcd(a,b)=gcd(b,a-b),所以我们要求的gcd(a+k,b+k)可以转化成gcd(b+k,a-b),令d=gcd(b+k,a-b),则d是a-b的因数,枚举这个因数,枚举过程中不断更新最小的lcm对应的k,若

  • SNOI2019场外VP记2019-05-03 20:53:41

    SNOI2019场外VP记 教练突然说要考一场别省省选来测试水平...正好还没看题那就当VP咯w... Day 1 八点开题打 .vimrc. 先看了看题目名...一股莫名鬼畜感袭来... 怎么T1就是字符串鸭?HEOI 2019 D1T2的心理阴影为啥我会xjb套那么多东西上去啊QAQ...T2数论T3通信? 不好的感觉... 读了读T

  • 牛牛与LCM2019-05-03 14:50:36

    来源:牛客网   牛牛最近在学习初等数论,他的数学老师给他出了一道题,他觉得太简单了, 懒得做,于是交给了你, 题目是这样的: 有一堆数,问你能否从中选出若干个数使得这些数的最小公倍数为x 输入描述: 第一行输入一个整数n(1 ≤ n ≤ 50) 第二行输入n个整数ai (1 ≤ ai ≤ 1e9) 第三行输入

  • C. Neko does Maths2019-04-30 17:53:49

    a+k与b+k的最小公倍数 求k最小 lcm=a∗b/gcd gcd(a,b)=gcd(a,b-a) a和b加上k之后产生的最大公因数必然是a-b的因子 求差值 枚举差值的所有因子 #include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+5;ll gcd(ll x,ll y) { return y==0 ? x: gcd(

  • POJ 3970(最小公倍数LCM)2019-04-26 12:54:19

     知识点:      最小公倍数(a,b)=a*b/最大公约数(a。b)                                                                                                      

  • Leetcode 858:镜面反射2019-04-24 20:48:21

    题目描述 有一个特殊的正方形房间,每面墙上都有一面镜子。除西南角以外,每个角落都放有一个接受器,编号为 0, 1,以及 2。 正方形房间的墙壁长度为 p,一束激光从西南角射出,首先会与东墙相遇,入射点到接收器 0 的距离为 q 。 返回光线最先遇到的接收器的编号(保证光线最终会遇到

  • G. Minimum Possible LCM (找出最小的最小公倍数(任意两个值))2019-04-18 19:56:05

    题目链接:哆啦A梦传送门 题意:给出一个序列,找出两个数,使得它们的最小公倍数最小。   题解: lcm(x,y)=x*y/gcd(x,y)。 我们直接枚举最大公约数d。只需找到最大公约数d的倍数的两个值就行了,因为再往后找,其lcm会越来越大。 复杂度为 O(nln(n)) ,因为假设每次二重循环达到最大,那么复

  • L - LCM Walk HDU - 5584 (数论)2019-04-16 10:49:18

    题目链接: L - LCM Walk  HDU - 5584  题目大意:首先是T组测试样例,然后给你x和y,这个指的是终点。然后问你有多少个起点能走到这个x和y。每一次走的规则是(m1,m2)到(m1+lcm(m1,m2),m2)或者(m1,m2+lcm(m1,m2))。 具体思路: lcm(m1,m2)=m1*m2/(gcd(m1,m2)).然后m1就能表示成t1*gcd(m1,m2),m2能表示成t2*gcd(m1,m

  • 第五次作业2019-04-14 13:49:20

    #include<stdio.h>int main(void){ int m,n,p,i,gcd,lcm; printf("enter two number:\n"); scanf("%d%d",&m,&n); p=m*n; lcm=p/m; while(n!=0){  i=m%n;  m=n;  n=i;} printf("The gcd is %d\n",m); printf("The lcm is

  • CodeForces - 55D Beautiful numbers (数位dp)2019-04-09 16:48:00

    Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers

  • GCD与LCM2019-04-07 16:43:45

    求最大公约数(GCD)和求最小公倍数(LCM); 首先是求最大公约数,我们可以利用辗转相除法来求 1 int gcd(int a,int b)2 {3 if(b==0)4 return a;5 return gcd(b,a%b);6 } 这就是GCD的核心代码。 剩下的LCM与gcd也有很大的关系,首先最大公约数也是最小公倍数的约数。 所以最

  • 最大公约数--最小公倍数--Java实现2019-03-31 11:51:22

    package cn.LanQiaoBeiAlgorithm.Ravanla; public class Max_GongYueShu { public static void main(String[] args) { // int a = 15; // int b = 40; // //最大公约数 // //从两数中较小的数开始,找出能整除本数的又能整除较大的数的数为最大公约数 // //最大公约数

  • cf55D. Beautiful numbers(数位dp)2019-03-17 19:43:22

    题意 题目链接 Sol 看到这种题就不难想到是数位dp了。 一个很显然的性质是一个数若能整除所有位数上的数,则一定能整除他们的lcm。 根据这个条件我们不难看出我们只需要记录每个数对所有数的lcm(也就是2520)取模的结果 那么\(f[i][j][k]\)表示还有\(i\)个数要决策,之前的数模\(2520\)

  • 杭电OJ_2028:Lowest Common Multiple Plus2019-03-03 16:47:48

    题目 核心思路 求两个数的最小公倍数采用辗转相除法; 多个数的最小公倍数只需要按照两数的最小公倍数求法依次进行;先求出前两个数的最小公倍数,在将所求结果和第三个数带入下一轮求解,以此推类; 代码分享&分析 #include<iostream> using namespace std; int GreatstCommonDiviso

  • ZOJ 2342 - 简单思维题2019-02-26 16:49:13

    题目链接:https://vjudge.net/problem/ZOJ-2343   解题思路: 如果可以取到一个k使得xi/Y - k/M ==0,那么肯定ki取k最好。 如果不存在这样的k就存在另一个k使得xi/Y - k/M > 0,xi/Y - (k+1)/M < 0。如果每个xi都对应取得这样的k那么显然最后∑k会<M,那么接下来就考虑有些xi要对应

  • GCD LCM(水题)2019-02-22 19:50:31

    Description 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 integers. A positive integer can be t

  • CF 55D Beautiful Numbers(数位DP)2019-02-18 21:37:29

    Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers

  • 算法训练 最大最小公倍数2019-02-15 20:45:03

     算法训练 最大最小公倍数   时间限制:1.0s   内存限制:256.0MB 问题描述 已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少。 输入格式 输入一个正整数N。 输出格式 输出一个整数,表示你找到的最小公倍数。 样例输入 9 样例输出 504 数据规模与约定

  • [Luogu5181][COCI2009]GENIJALAC2019-02-13 15:44:06

    题目链接: Luogu5181 一个简单题? 首先对\([C+1,n-D]\)中的每个数字求出循环节,求\(Lcm\)即是整段的循环节。 然后判断\([A,B]\)中有几个数满足\(x-1\equiv 0(mod\ Lcm)\)。 求循环节暴力可过。。 其实求循环节是可以\(O(n)\)的。 每一次求循环节得到一个环,那么环上所有点的循环节都是

  • hdu4497-GCD and LCM-(欧拉筛+唯一分解定理+组合数)2019-02-09 20:41:03

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3409    Accepted Submission(s): 1503 Problem Description Given two positive integers G and L, could you tell me how many solutions of

  • [HDU 5382] GCD?LCM!2019-02-09 11:43:48

    Description First we define: (1) \(lcm(a,b)\), the least common multiple of two integers \(a\) and \(b\), is the smallest positive integer that is divisible by both \(a\) and \(b\). for example, \(lcm(2,3)=6\) and \(lcm(4,6)=12\). (2) \(gcd

  • POJ2429--GCD & LCM Inverse (UNSOLVED)2019-02-09 11:41:02

    Given two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the least common multiple (LCM) of a and b. But what about the inverse? That is: given GCD and LCM, finding a and b. Input The input contains multiple test

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

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

ICode9版权所有