
gcd 快速幂 素筛
心夏心冬
心夏心冬
展开
-
cake
There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into原创 2017-01-28 10:36:07 · 196 阅读 · 0 评论 -
WisKey的眼神 HDU - 1577 gcd
DescriptionWisKey的眼镜有500多度,所以眼神不大好,而且他有个习惯,就是走路喜欢看着地(不是为了拣钱哦^_^),所以大家下次碰见他的时候最好主动打下招呼,呵呵. 但是Rabbit总是喜欢扮神秘,一天WisKey去食堂排队等着买饭,突然收到一道短消息,是Rabbit发的,”呵呵,又看见你了,你没看到我吧”.WisKey马上拉长脖子扫描食堂,可是就是看不到,再发短信问Rabbit在原创 2017-07-30 09:46:52 · 291 阅读 · 0 评论 -
CodeForces - 346A gcd
DescriptionIt is so boring in the summer holiday, isn’t it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take原创 2017-07-20 14:48:25 · 210 阅读 · 0 评论 -
Finding LCM gcd
LCM is an abbreviation used for Least Common Multiple in Mathematics. We say LCM (a, b, c) = L if and only if L is the least integer which is divisible by a, b and c.You will be given a, b and L. You h原创 2017-04-14 11:25:35 · 451 阅读 · 0 评论 -
How Many Points? gcd
Given two points A and B on the X-Y plane, output the number of the lattice points on the segment AB. Note that A and B are also lattice point. Those who are confused with the definition of lattice poi原创 2017-04-14 10:03:22 · 636 阅读 · 0 评论 -
Translate
问题 E: Translate 时间限制: 1 Sec 内存限制: 128 MB提交: 32 解决: 7 题目描述 你N个正整数a[1]…a[N],在最初的时候,你选择一个正整数X,然后以后每一步,你可以使一个数a[i] 变成 a[i] + X,或者 a[i] - X,聪明的你,一定会知道怎么选择这个X,使得最后所有的数都变成相等,而且使用的变化步数最少。输入 多组测试数据。对于每组数据,一原创 2017-02-26 13:45:25 · 542 阅读 · 1 评论 -
Raising Modulo Numbers
People are different. Some secretly read magazines full of interesting girls' pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult mathematical games.原创 2017-01-30 19:47:19 · 487 阅读 · 0 评论 -
Pseudoprime numbers
Fermat's theorem states that for any prime number p and for any integer a > 1, ap= a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but not very many) no原创 2017-01-30 19:45:13 · 242 阅读 · 0 评论 -
key set
soda has a set SS with nn integers {1,2,…,n}{1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of SS are key set.原创 2017-01-30 19:43:02 · 361 阅读 · 0 评论 -
the sum of cube 立方和
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.InputThe first line of the input is T(1 Each case of input is a pair of intege原创 2017-01-30 19:41:52 · 316 阅读 · 0 评论 -
不要62
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 88914 都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉原创 2017-01-30 19:40:44 · 368 阅读 · 0 评论 -
美素数
小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识。 问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为“美素数”,如29,本身是素数,而且2+9 = 11也是素数,所以它是美素数。 给定一个区间,你能计算出这个区间内有多少个美素数吗?Input第一行输入一个正整数T,表示总共有T组数据(T 接下来共T原创 2017-01-30 19:38:02 · 242 阅读 · 0 评论 -
分拆素数和
把一个偶数拆成两个不同素数的和,有几种拆法呢?Input输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。Output对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。Sample Input30260Sample Output32思路 两个不相等的素数之和等于这个数即可 直接打表 #includei原创 2017-01-30 19:34:49 · 263 阅读 · 0 评论 -
素数判定
对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39Input输入数据有多组,每组占一行,由两个整数x,y组成,当x=0,y=0时,表示输入结束,该行不做处理。Output对于每个给定范围内的取值,如果表达式的值都为素数,则输出"OK",否则请输出“Sorry”,每组输出占一行。 Sample Input0 10 0Sample Ou原创 2017-01-30 19:32:50 · 190 阅读 · 0 评论 -
又见GCD
有三个正整数a,b,c(0Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。 Output输出对应的c,每组测试数据占一行。 Sample Input26 212 4Sample Output48思路a c 分别除以他们的最大公约数 得到的两个结果是互质的 枚举一下即可#includein原创 2017-01-29 19:10:20 · 480 阅读 · 0 评论 -
wolf and rabbit
There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into原创 2017-01-29 19:04:45 · 262 阅读 · 0 评论 -
大素数判定法
kuangbin聚聚的模板#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>#include<iostream>#include<algorithm>using namespace std;const int S=2...原创 2018-07-31 19:08:21 · 856 阅读 · 0 评论