数论
weixin_44705665
这个作者很懒,什么都没留下…
展开
-
POJ 2773 欧几里德或欧拉函数+容斥原理+二分
Two positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9…are all relatively prime to 2006. Now your job is easy: for the ...原创 2019-08-15 15:39:30 · 85 阅读 · 0 评论 -
1213D2-按分区均衡化(硬体版本)
The only difference between easy and hard versions is the number of elements in the array. You are given an arrayaaconsisting ofnnintegers. In one move you can choose anyaiaiand divide it by22...原创 2019-09-02 00:03:56 · 177 阅读 · 0 评论 -
POJ 2115 C Looooops 扩展欧几里德算法
A Compiler Mystery: We are given a C-language style for loop of type for (variable = A; variable != B; variable += C) statement; I.e., a loop which starts by setting variable to value A and while vari...原创 2019-08-17 10:42:25 · 99 阅读 · 0 评论 -
POJ 2478 欧拉函数
The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are F2 =...原创 2019-08-17 09:58:21 · 79 阅读 · 0 评论 -
HDU 2669 (扩展欧几里德算法)
The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lovers Walk passing, and so are You. …Write in English class by yifen...原创 2019-08-17 09:33:24 · 124 阅读 · 0 评论 -
HDU 2824 (欧拉函数)
The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful c...原创 2019-08-16 21:13:24 · 131 阅读 · 0 评论 -
POJ 1061 拓展欧几里德
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,...原创 2019-08-16 19:49:17 · 60 阅读 · 0 评论 -
HDU 1395 2^x mod n = 1
Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1. Input One positive integer on each line, the value of n. Output If the minimum x exists, print a line with 2^x mod n = 1. Prin...原创 2019-08-16 17:12:37 · 60 阅读 · 0 评论 -
POJ 2689 大区间素数筛选
The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the question of primali...原创 2019-08-16 16:34:04 · 64 阅读 · 0 评论 -
HDU 1576 (扩展欧几里得算法+试探法)
要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。 Input 数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。 Output 对应每组数据输出(A/B)%9973。 Sample Input 2 1000 53...原创 2019-08-16 14:18:17 · 78 阅读 · 0 评论 -
CodeForces - 1028B (数论)
s(x)表示x每位数的数字和。现在给你两个整数n,m,请找出两个符合下列条件的整数a,b: 1. s(a) >= n 2. s(b) >= n 3. s(a+b) <= m Input 输入两个整数n,m。(1 <= n,m <= 1129) Output 输出两个正整数a,b。本题特判,如有多种答案,输出任意一种即可。(a,b都没有前导零,a,b的位数都不...原创 2019-08-25 20:36:41 · 262 阅读 · 0 评论 -
LightOJ 1245 除法分块
I was trying to solve problem ‘1234 - Harmonic Number’, I wrote the following code long long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) res = res + n / i; return res; } Yes, my e...原创 2019-08-16 09:43:38 · 111 阅读 · 0 评论 -
hdu2685(快速幂+gcd定理)
To think of a beautiful problem description is so hard for me that let’s just drop them off.原创 2019-08-15 20:20:34 · 166 阅读 · 0 评论 -
HDU 1787 GCD Again(欧拉函数入门)
Do you have spent some time to think and try to solve those unsolved problem after one ACM contest? No? Oh, you must do this when you want to become a “Big Cattle”. Now you will find that this problem...原创 2019-08-15 19:23:49 · 135 阅读 · 0 评论 -
Lightoj1259——Goldbach`s Conjecture(哥德巴赫猜想)
Goldbach’s conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states: Every even integer, greater than 2, can be expressed as the sum of two primes [1]. N...原创 2019-08-15 17:41:03 · 79 阅读 · 0 评论 -
LightOJ 1214 Large Division(大整数取模)
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c. I...原创 2019-08-15 16:36:03 · 79 阅读 · 0 评论 -
Codeforces Round #587 (Div. 3) Swords (gcd)
题目链接 题意:地下室有相同数目各种不同类型的剑,一群人盗剑,每人只能拿一种类型的剑,且每人拿剑数目相同,至少有一种剑未被盗,已知n种剑,和地下室被盗之后各种剑数目,求最少多少人盗剑,每人盗几把。 思路: 求被盗各种剑的最大公约数。 代码如下: #include<bits/stdc++.h> #define ll long long #define N 200010 us...原创 2019-09-22 08:11:46 · 109 阅读 · 0 评论