hdu-5505(数论)】的更多相关文章

GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1818    Accepted Submission(s): 490 Problem Description You are given two numbers N and M. Every step you can get a new N in the wa…
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_1^{k_1})*(p_2^{k_2})*(p_3^{k_3})\dots \] \…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4497 解题思路:将满足条件的一组x,z,y都除以G,得到x‘,y',z',满足条件gcd(x',y',x') = 1,同时lcm(x',y',x') = G/L. 特判,当G%L != 0 时,无解. 然后素数分解G/L,假设G/L = p1^t1 * p2^t2 *````* pn^tn. 满足上面条件的x,y,z一定为这样的形式. x' = p1^i1 * p2^i2 *```* pn^in.…
题目链接 : http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=641&pid=1002 思路 : N有若干个质因子, N = a^b * c^d * e^f...... M也有若干个质因子, M = a^(b+k) * c(d+k1) * e^(f+k2)...... N能到达M的条件是它们的质因子必须完全相同 N每次可以乘上它的若干个质因子, 直到这个质因子的幂次等于M这个质因子的幂次 考虑这样一个事实,…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4542 小明系列故事--未知剩余系 Time Limit: 500/200 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 889    Accepted Submission(s): 207 Problem Description "今有物不知其数,三三数之有二,五五数之有三,七七数之有…
http://acm.hdu.edu.cn/showproblem.php?pid=4961 给定ai数组; 构造bi, k=max(j | 0<j<i,a j%ai=0), bi=ak; 构造ci, k=min(j | i<j≤n,aj%ai=0), ci=ak; 求所有bi∗ci的和 f[x]表示能整除x的最近的下标,边构造边更新f数组,复杂度约为O(N*sqrt(A[I])) = O(10^7),可以接受,然后把所有b*c加起来即可 另外,我写的程序里面c[i]指的是上面说的b[i…
Different Digits Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1430    Accepted Submission(s): 392 Problem Description Given a positive integer n, your task is to find a positive integer m, w…
http://acm.hdu.edu.cn/showproblem.php?pid=3641 学到: 1.二分求符合条件的最小值 /*==================================================== 二分查找符合条件的最小值 ======================================================*/ ll solve() { __int64 low = 0, high = INF, mid ; while(low <=…
http://acm.hdu.edu.cn/showproblem.php? pid=4059 现场赛中通过率挺高的一道题 可是容斥原理不怎么会.. 參考了http://blog.csdn.net/acm_cxlove/article/details/7434864 1.求逆元   p=1e9+7是素数.所以由 a^(p-1)%p同余于1 可得a%p的逆元为a^(p-2) 2.segma(i^k)都能够通过推导得到求和公式 详见http://blog.csdn.net/acm_cxlove/ar…
GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1520    Accepted Submission(s): 381 Problem Description You are given two numbers N and M. Every step you can get a new N in the wa…
题意: 给你a和b,a每次和它的因子相乘得到一个新的a,求多少次后可以得到b. 输入样例 3 1 1 1 2 2 4 输出样例 0 -1 1 思路: 每次找出a和b/a的最大公约数(即当前a想得到b能乘的最大数),再进行判断. 第一次直接暴力搞,超时了,发现题意理解错了 T_T. 用unsign按着题意做即可. #include <iostream> #include <cstdio> #include <vector> #include <queue> #…
别人的解题报告: http://blog.csdn.net/zstu_zlj/article/details/9796087 我的代码: #include <cstdio> #define N 100020 ; int p[N]; void Partition() { p[] =; ; n <= 1e5; ++n) { ; ; while(true) { *k-)/; ) break; p[n] = (p[n]+fac*p[t])%mod; ) p[n] = (p[n]+fac*p[t-…
HeHe Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1463    Accepted Submission(s): 475 Problem Description In the equation X^2≡X(mod N) where x∈[0,N-1], we define He[N] as the number of soluti…
Dertouzos Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 891    Accepted Submission(s): 274 Problem Description A positive proper divisor is a positive divisor of a number n, excluding n itse…
Misaki's Kiss again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1621    Accepted Submission(s): 414 Problem Description After the Ferries Wheel, many friends hope to receive the Misaki's kis…
a/b + c/d Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 14895    Accepted Submission(s): 7761 Problem Description 给你2个分数,求他们的和,并要求和为最简形式.   Input 输入首先包含一个正整数T(T<=1000),表示有T组测试数据,然后是T行数据,每行包含四个…
Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1847    Accepted Submission(s): 629 Problem Description Alexandra has a little brother. He is new to programming. One…
GT and numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 683    Accepted Submission(s): 190 Problem Description You are given two numbers N and M. Every step you can get a new N in the way…
f(n) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 457    Accepted Submission(s): 279 Problem Description This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+…+Gc…
I won't tell you this is about number theory Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 458    Accepted Submission(s): 142 Problem Description To think of a beautiful problem description is…
Remainder Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2122    Accepted Submission(s): 449 Problem Description Coco is a clever boy, who is good at mathematics. However, he is puzzled by a d…
Boring Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 60    Accepted Submission(s): 30 Problem Description    Number theory is interesting, while this problem is boring.   Here is the pr…
GT and numbers 问题描述 给出两个数NN和MM. NN每次可以乘上一个自己的因数变成新的NN. 求最初的NN到MM至少需要几步. 如果永远也到不了输出-1−1. 输入描述 第一行读入一个数TT表示数据组数. 接下来TT行,每行两个数NN和MM. T\leq1000T≤1000, 1\leq N \leq 10000001≤N≤1000000,1 \leq M \leq 2^{63}1≤M≤2​63​​. 注意M的范围.hack时建议输出最后一行的行末回车;每一行的结尾不要输出空格.…
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + n$,也就是求n^2的因子数量 /** @Date : 2017-09-08 10:45:12 * @FileName: HDU 1299 数论 分解.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5768 题目大意: T组数据,求L~R中满足:1.是7的倍数,2.对n个素数有 %pi!=ai  的数的个数. 题目思路: [中国剩余定理][容斥原理][快速乘法][数论] 因为都是素数所以两两互素,满足中国剩余定理的条件. 把7加到素数中,a=0,这样就变成解n+1个同余方程的通解(最小解).之后算L~R中有多少解. 但是由于中国剩余定理的条件是同时成立的,而题目是或的关系,所以要用容斥原理叠加删…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2114 自己对数论一窍不通啊现在,做了一道水题,贴出来吧...主要是让自己记住这个公式: 前n项和的立方公式为   : s(n)=(n*(n+1)/2)^2; 前n项和的平方公式为:s(n)=n*(n+1)(2*n+1)/6; 代码: #include<iostream> #include<cstdlib> #include<cstdio> using namespace s…
HDU 1005 Number Sequence(数论) Problem Description: A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n).   Input The input consists of multipl…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............……………...(1) 则…................................….…(2) 为什么是这样呢,因为我们知道 同理得到b的分解和的分解 我们会发现,虽然a和b的分解里可以有相等的部分,但是在里的也就是我们假设为的部分是不会有重复的,那么要由*得出也就是要去除重复部分,的重复部分就是…
Special Prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 738    Accepted Submission(s): 390 Problem Description Give you a prime number p, if you could find some natural number (0 is not in…
求所有不超过1e9的 primitive Pythagorean triple中第2大的数取模$2^k$作为下标,对应a[i]数组的和. 先上WIKI:https://en.wikipedia.org/wiki/Pythagorean_triple 里面有通过欧几里得公式来得到有关毕达哥拉斯式子的一些性质. 最后得到的一个关于互质的m,n变种的式子更加直观,因此枚举m,n,保证其合法.每次枚举n,筛掉和n有共同因子的m,范围是$\sqrt{1e9}$.然后由于要求的是b,而且取模的都是2的幂指,…