HDU 5514.Frogs-欧拉函数 or 容斥原理】的更多相关文章

题意: 有\(m(1 \leq m \leq 10^9)\)个石子排成一圈,编号分别为\(0,1,2 \cdots m-1\). 现在在\(0\)号石头上有\(n(1 \leq n \leq 10^4)\)只青蛙.第\(i\)只青蛙每次能往前跳\(a_i\)步,但是他们跳的次数不加限制. 如果一块石头能至少被一只青蛙跳上去,那么称这块石头被占领了. 求所有可能被占领的石头的编号和. 分析: 首先我们应该发现这样一个事实: 每次向前跳\(a_i\)步的效果和跳\(GCD(a_i, m)\)步是一样…
GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9046    Accepted Submission(s): 3351 Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y…
GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5064    Accepted Submission(s): 1818 Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y)…
GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7357    Accepted Submission(s): 2698 Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y…
1.HDU 2824   The Euler function 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=2824 3.总结:欧拉函数 题意:求(a,b)间的欧拉函数值的和. #include<iostream> #include<cstring> #include<cmath> #include<queue> #include<algorithm> #include<cstdio>…
输入a b c d k求有多少对x y 使得x在a-b区间 y在c-d区间 gcd(x, y) = k 此外a和c一定是1 由于gcd(x, y) == k 将b和d都除以k 题目转化为1到b/k 和1到d/k 2个区间 如果第一个区间小于第二个区间 讲第二个区间分成2部分来做1-b/k 和 b/k+1-d/k 第一部分对于每一个数i 和他互质的数就是这个数的欧拉函数值 全部数的欧拉函数的和就是答案 第二部分能够用全部数减去不互质的数 对于一个数i 分解因子和他不互质的数包括他的若干个因子 这个…
GCD Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4141    Accepted Submission(s): 1441 Problem Description Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y)…
GuGuFishtion \[ Time Limit: 1500 ms\quad Memory Limit: 65536 kB \] 题意 给出定义\(Gu(a, b) = \frac{\phi(ab)}{\phi(a)\phi(b)}\) 求出\(\sum_{a=1}^{m}\sum_{b=1}^{n}Gu(a,b) (mod p)\) 思路 首先对于欧拉函数,我们知道欧拉函数的朴素式子为:\(\phi(n) = n*(1-\frac{1}{p1})*(1-\frac{1}{p2}) * ..…
GCD Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For examp…
题目链接 Problem Description Multiple query, for each n, you need to get $$$$$$ \sum_{i=1}^{n} \sum_{j=1}^{i-1}{ [gcd(i + j, i - j) = 1]} $$$$$$ Input On the first line, there is a positive integer T, which describe the number of queries. Next there are…