数论
文章平均质量分 70
「已注销」
我不管这个世上的人怎么说我,我只想依照我的信念做事,绝不后悔,不管现在将来都一样!
展开
-
Maximum GCD
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible pair of these integers. Input The first line of input is an integer N (1 < N < 100) that determin...原创 2018-08-28 08:50:24 · 514 阅读 · 0 评论 -
1247 可能的路径
在一个无限大的二维网格上,你站在(a,b)点上,下一步你可以移动到(a + b, b), (a, a + b), (a - b, b), 或者 (a, a - b)这4个点。 给出起点坐标(a,b),以及终点坐标(x,y),问你能否从起点移动到终点。如果可以,输出"Yes",否则输出"No"。 例如:(1,1) 到 (2,3),(1,1) -> (2,1) -> (2,3)。 收...原创 2019-02-21 13:50:17 · 222 阅读 · 0 评论 -
1390 游戏得分
A与B两人玩一个游戏,这个游戏有若干个回合(可能0回合)。游戏的回合依次标号为1,2,3,4...。你不需要关心游戏的内容,现在只要知道第i回合胜者会获得2*i-1分,每回合游戏不存在平局。现在已知A和B在游戏结束时各获得了x分与y分的总分。问A在这个游戏中至少获胜了几盘?如果给出的x与y一定不会出现那么输出-1. 收起 输入 多组测试数据,第一行一个整数T,表示测试数据数量,1<=...原创 2019-02-15 17:02:53 · 143 阅读 · 0 评论 -
1179 最大的最大公约数
给出N个正整数,找出N个数两两之间最大公约数的最大值。例如:N = 4,4个数为:9 15 25 16,两两之间最大公约数的最大值是15同25的最大公约数5。 收起 输入 第1行:一个数N,表示输入正整数的数量。(2 <= N <= 50000) 第2 - N + 1行:每行1个数,对应输入的正整数.(1 <= S[i] <= 1000000) 输出 输出两两...原创 2019-02-16 10:03:49 · 413 阅读 · 3 评论 -
1639 绑鞋带
有n根鞋带混在一起,现在重复n次以下操作:随机抽出两个鞋带头,把它们绑在一起。可以想象,这n次之后將不再有单独的鞋带头,n条鞋带系成了一些环。那么有多大概率刚好所有这些鞋带只形成了一个环? 收起 输入 仅一行,包含一个整数n (2<=n<=1000)。 输出 输出一行,为刚好成环的概率。 输入样例 2 输出样例 0.666667 数学的重要性,考虑n根鞋带...原创 2019-02-16 13:32:55 · 177 阅读 · 0 评论 -
1267 4个数和为0
给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出"Yes",否则输出"No"。 收起 输入 第1行,1个数N,N为数组的长度(4 <= N <= 1000) 第2 - N + 1行:A[i](-10^9 <= A[i] <= 10^9) 输出 如果可以选出4个数,使得他们的和为0,则输出"Yes",否则输出"No"。 输入样例 5原创 2019-02-16 14:34:50 · 389 阅读 · 0 评论 -
1013 3的幂的和
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007 收起 输入 输入一个数N(0 <= N <= 10^9) 输出 输出:计算结果 输入样例 3 输出样例 40 快速幂应该不陌生了,算法书上有,至于等比数列就得回顾高中的知识了,你根据等比数列求和,然后快速幂就可以。 #include<stdio.h> #include...原创 2019-02-17 14:51:52 · 240 阅读 · 0 评论 -
1126 求递推序列的第N项
有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A,B和N,求f(n)的值。 收起 输入 输入3个数:A,B,N。数字之间用空格分割。(-10000 <= A, B <= 10000, 1 <= N <= 10^9) 输出 输出f(n)的值。 ...原创 2019-02-12 10:01:16 · 202 阅读 · 0 评论 -
1396 还是01串
给定一个0-1串s,长度为n,下标从0开始,求一个位置k,满足0<=k<=n, 并且子串s[0..k - 1]中的0的个数与子串s[k..n - 1]中1的个数相等。 注意: (1) 如果k = 0, s[0..k - 1]视为空串 (2) 如果k = n, s[k..n - 1]视为空串 (3) 如果存在多个k值,输处任何一个都可以 (4) 如果不存在这样的k值,请输出-1 ...原创 2019-02-18 17:18:06 · 186 阅读 · 0 评论 -
1615 跳跃的杰克
杰克最近正在努力锻炼他的跳跃技能。当前他正站在X坐标轴原点上。他想跳到坐标(x,0)上,为了达到训练效果,他决定首次跳跃的距离是1,之后每一次跳跃的距离将会比上一次跳跃的距离大1个单位。每一次跳跃,他可以选择往左或者往右跳。他很好奇至少要经过多少次跳跃才能到达终点。 输入 单组测试数据。 输入数据只包含整数x(-10^9<=x<=10^9)。 输出 输出杰克到达终点所需要的...原创 2019-02-13 09:23:18 · 200 阅读 · 0 评论 -
1419 最小公倍数挑战
几天以前,我学习了最小公倍数。玩得挺久了,想换换口味。 我不想用太多的数字,我想从1到n中选三个数字(可以相同)。使得他们的最小公倍数最大。 收起 输入 单组测试数据。 第一行有一个整数n (1≤n≤1,000,000)。 输出 输出一个整数表示选三个数字的最大的最小公倍数。 输入样例 9 7 输出样例 504 210 最近做题有些水逆,这个题错了好几次,本以为最小...原创 2019-02-15 15:48:04 · 166 阅读 · 0 评论 -
B - Math
JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer nn , you can perform the following operations ...原创 2018-11-29 21:56:25 · 272 阅读 · 0 评论 -
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...原创 2018-08-28 17:07:46 · 86 阅读 · 0 评论 -
Farey Sequence
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 =...原创 2018-08-28 17:42:00 · 206 阅读 · 0 评论 -
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]. ...原创 2018-08-29 11:02:45 · 288 阅读 · 0 评论 -
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. ...原创 2018-08-29 11:50:20 · 137 阅读 · 0 评论 -
Prime Time
Euler is a well-known matematician, and, among many other things, he discovered that the formula n2 +n+41 produces a prime for 0 ≤ n < 40. For n = 40, the formula produces 1681, which is 41∗41. Eve...原创 2018-08-29 15:03:50 · 933 阅读 · 1 评论 -
Harmonic Number (II)
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; ret...原创 2018-08-30 10:19:38 · 417 阅读 · 0 评论 -
Leading and Trailing
You are given two integers: n and k, your task is to find the most significant three digits, and least significant three digits of nk. Input Input starts with an integer T (≤ 1000), denoting the num...原创 2018-09-02 14:45:43 · 182 阅读 · 0 评论 -
Line
A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from - 5·1018 to 5·1018 inclusive, or to find out that s...原创 2018-09-02 20:43:38 · 133 阅读 · 0 评论 -
Harmonic Number
In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are given n, you have to find Hn. Input Input starts with an integer T...原创 2018-09-02 21:04:09 · 341 阅读 · 0 评论 -
1116 K进制下的大数
有一个字符串S,记录了一个大数,但不知这个大数是多少进制的,只知道这个数在K进制下是K - 1的倍数。现在由你来求出这个最小的进制K。 例如:给出的数是A1A,有A则最少也是11进制,然后发现A1A在22进制下等于4872,4872 mod 21 = 0,并且22是最小的,因此输出k = 22(大数的表示中A对应10,Z对应35)。 收起 输入 输入大数对应的字符串S。S的长度小于10^...原创 2019-02-20 11:55:51 · 198 阅读 · 0 评论