
数论
文章平均质量分 61
心夏心冬
心夏心冬
展开
-
青蛙的约会 扩展欧几里得
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你原创 2017-04-11 20:28:20 · 374 阅读 · 1 评论 -
HDU - 4135Co-prime 容斥 分解质因子
DescriptionGiven a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be co-prime or relatively prime if they原创 2017-07-24 10:26:57 · 315 阅读 · 0 评论 -
HDU - 1695 GCD 容斥+欧拉线性筛法
DescriptionGiven 5 integers: a, b, c, d, k, you’re to find x in a…b, y in c…d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large,原创 2017-07-23 12:17:27 · 272 阅读 · 0 评论 -
51Nod - 1284 2 3 5 7的倍数 容斥
Description给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数Input输入1个数N(1 <= N <= 10^18)。Output输出不是2 3 5 7的倍数的数共有多少。Sample Input10Sample Output1Hint题意题解:容斥原理 奇加偶减 求1~n中一些数的倍数的个数 如果是求m与1~n中互质的数的个原创 2017-07-23 12:08:18 · 293 阅读 · 0 评论 -
POJ - 1142 Smith Numbers 分治 分解质因子
DescriptionWhile skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University,noticed that the telephone number of his brother-in-law H. Smith had the following peculiar原创 2017-07-23 12:00:45 · 355 阅读 · 0 评论 -
****HDU - 2841Visible Trees 容斥+欧拉函数
DescriptionThere are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) point. He wonders how many trees he can see. If two trees and Sherlock are in one原创 2017-07-23 16:42:34 · 316 阅读 · 0 评论 -
吃糖果 HDU - 1205 抽屉原理
DescriptionHOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。 Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0Output对于每组数据,输出一原创 2017-07-30 16:02:21 · 279 阅读 · 0 评论 -
HDU 6053 TrickGCD 线性筛 思维 容斥
杭电6053TrickGCDTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2187 Accepted Submission(s): 846Problem DescriptionYou are given an array A , a原创 2017-07-30 11:37:49 · 220 阅读 · 0 评论 -
求递推序列的第N项 51Nod - 1126
Description有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A,B和N,求f(n)的值。Input输入3个数:A,B,N。数字之间用空格分割。(-10000 <= A, B <= 10000, 1 <= N <= 10^9)Output输出f(n)的值。Sample Input3原创 2017-07-30 08:32:18 · 257 阅读 · 0 评论 -
qwb与神奇的序列 同余定理
Descriptionqwb又遇到了一道题目:有一个序列,初始时只有两个数x和y,之后每次操作时,在原序列的任意两个相邻数之间插入这两个数的和,得到新序列。举例说明:初始:1 2 操作1次:1 3 2 操作2次:1 4 3 5 2 …… 请问在操作n次之后,得到的序列的所有数之和是多少?Input多组测试数据,处理到文件结束(测试例数量<=50000)。输入为一行三个整数x,y,n,相邻两个原创 2017-06-03 23:14:26 · 397 阅读 · 0 评论 -
简单求和
Description小Kevin从没有听说过单词“无限”。于是他请导师给他解释这个词。他的导师知道“无限”是一个非常大的数。为了展示无限可能有多大, 他的导师给了他一个挑战: 求从1到 N的数的和。和数开始变得非常大,并且已经超出了“long long int”的表示范围。于是,这一课非常清晰。现在,他的导师引入了取余的概念并让他只保留余数而非巨大的数。 然后, 导师给了他一个计算的公式:Inpu原创 2017-06-05 20:07:07 · 261 阅读 · 0 评论 -
qwb与支教 二分加容斥
Descriptionqwb同时也是是之江学院的志愿者,暑期要前往周边地区支教,为了提高小学生的数学水平。她把小学生排成一排,从左至右从1开始依次往上报数。玩完一轮后,他发现这个游戏太简单了。于是他选了3个不同的数x,y,z;从1依次往上开始报数,遇到x的倍数、y的倍数或z的倍数就跳过。如果x=2,y=3,z=5;第一名小学生报1,第2名得跳过2、3、4、5、6,报7;第3名得跳过8、9、10,报1原创 2017-06-04 21:26:57 · 319 阅读 · 0 评论 -
Aladdin and the Flying Carpet 唯一分解定理
DescriptionIt’s said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter t原创 2017-04-23 18:06:47 · 391 阅读 · 0 评论 -
Joseph's Problem 数论 找规律
Joseph likes taking part in programming contests. His favorite problem is, of course, Joseph’s problem. It is stated as follows. There are n persons numbered from 0 to n - 1 standing in a circle. The原创 2017-04-20 23:06:00 · 676 阅读 · 1 评论 -
Bi-shoe and Phi-shoe 线筛欧拉函数
Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go原创 2017-04-18 22:03:03 · 387 阅读 · 0 评论 -
Pairs Forming LCM 唯一分解定理
Find the result of the following code:long long pairsFormLCM( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) for( int j = i; j <= n; j++ ) if( lcm(i, j) == n原创 2017-04-18 18:26:47 · 424 阅读 · 0 评论 -
zzuli 2173 数学
题目大意.n个人报数从左报到右再从右报到左 知道所有人都报到k的倍数思路找规律发现 k*a-(2*n-2)*b = c 要求c取到1到n所有数 这就要求gcd(k,2*n-2)==1 否则取不到#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<stack>#include<queue>原创 2017-08-22 17:05:13 · 300 阅读 · 0 评论