数论
。。。。。。。??
这个作者很懒,什么都没留下…
展开
-
[蓝桥杯2017初赛] k倍区间
题目描述给定一个长度为N的数列,A1, A2, ... AN。如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数,我们就称这个区间[i, j]是K倍区间。你能求出数列中总共有多少个K倍区间吗?输入第一行包含两个整数N和K。(1 <= N, K <= 100000)以下N行每行包含一个整数Ai。(1 <= Ai <= 100000)输出输出一个整数,代表K倍区间的数目。样例输入5...原创 2020-10-14 19:26:45 · 465 阅读 · 1 评论 -
题目 2272: [蓝桥杯][2016年第七届真题]最大比例
题目描述X星球的某个大奖赛设了M级奖励。每个级别的奖金是一个正整数。并且,相邻的两个级别间的比例是个固定值。也就是说:所有级别的奖金数构成了一个等比数列。比如:16,24,36,54其等比值为:3/2现在,我们随机调查了一些获奖者的奖金数。请你据此推算可能的最大的等比值。输入第一行为数字 N (0<N<100),表示接下的一行包含N个正整数第二行N个正整数Xi(Xi<1 000 000 000 000),用空格分开。每个整数表示调查到的某人的奖金数额输出.原创 2020-10-13 14:36:36 · 225 阅读 · 0 评论 -
A - LCM from 1 to n ----Light 1289
Given an integern, you have to findlcm(1, 2, 3, ..., n)lcmmeans least common multiple. For example lcm(2, 5, 4) = 20, lcm(3, 9) = 9, lcm(6, 8, 12) = 24.InputInput starts with an integerT (≤ 10000), denoting the number of test cases.Each case ...原创 2020-05-16 22:19:39 · 108 阅读 · 0 评论 -
Codeforce #511(Div 2) C. Enlarge GCD
Mr. F hasnpositive integers,a1,a2,…,an.He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.But this problem is too simple for him, so he does not want to do it by himself....原创 2020-05-15 20:54:11 · 120 阅读 · 0 评论 -
求素数的几种方法 ——(线性筛法)
求N以内的 所有素数(N <=1000000)求素数的方法1: 暴力#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>using namespace std;int su[1000010];int prime(int n){ for(int i=2;i<n;i++) { if(n%i==0) ..原创 2020-05-14 23:41:44 · 539 阅读 · 0 评论 -
“科大讯飞杯”第十七届同济大学程序设计预选赛 -------- A 张老师和菜哭武的游戏
题目描述天才程序员菜哭武和张老师有一天到一个城市旅游,旅途中菜哭武觉得无聊就想和张老师玩一个游戏。菜哭武有n个石子,每个石子都标有1到n之间到数,且各不相同,一开始他们会随机从这堆石子选一个石子放置到一个集合中,张老师选的数是a,菜哭武选的是b(a和b不相同)。接下来菜哭武和张老师轮流按照如下规则拿走一个石子:当石子x能被拿走时,当且仅当集合存在y和z,满足x等于y+z或者y-z,当x被拿走时,把它放到集合中。谁完成最后一轮操作时,谁获胜。张老师总是先手,于是张老师就好奇当决定好a和b时,他是否总是能.原创 2020-05-10 22:50:23 · 137 阅读 · 0 评论 -
关灯问题
题目描述今年就这么结束了, zdw感到十分失望蓝桥杯写错签到题, cf rating狂掉, 最后区域赛打铜, 还突然变成JBer了失落的zdw准备睡觉(真咸鱼), 他想关灯, 然而发现开关坏了zdw愤怒地敲击着开关, 然后发现一个很神奇的事情:如果灯之前已经关过了xx次, 那么下一次打开它以后再关上它需要使用x+1x+1次开关具体情况请参考样例. 一开始灯是开着的...原创 2019-08-03 20:53:18 · 161 阅读 · 0 评论 -
Find The Multiple
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there...原创 2019-07-21 16:38:06 · 69 阅读 · 0 评论 -
求一个数的所有真因子的和的方法
方法一:利用唯一分解定理。 任何一个大于一的自然数N,如果N不为质数,那么N可以唯一分解成有限个质数的乘积。 N=pow(p1,a1)*pow(p2,a2)*pow(p3,a3)*....*pow(pn,an); 全体正因数和: sum=(1+pow(p1,1)+pow(p...原创 2019-09-14 09:39:18 · 8734 阅读 · 0 评论 -
Intersection -------HDU - 5120 (求两环相交的面积)
Matt is a big fan of logo design. Recently he falls in love with logo made up by rings. The following figures are some famous examples you may know.A ring is a 2-D figure bounded by two circles...原创 2019-12-19 21:48:13 · 117 阅读 · 0 评论 -
A/B 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 Input2...原创 2019-09-25 21:30:59 · 92 阅读 · 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 g...原创 2019-08-09 19:35:27 · 141 阅读 · 0 评论 -
Number of Containers (数学题) ZOJ - 3175
For two integersmandk,kis said to be a container ofmifkis divisible bym. Given 2 positive integersnandm(m<n), the function f(n,m) is defined to be the number of containers ofmwh...原创 2019-08-15 09:18:18 · 192 阅读 · 0 评论 -
Intelligent Factorial Factorization (聪明的阶乘分解)
Given an integerN, you have to prime factorizeN!(factorialN).InputInput starts with an integerT (≤ 125), denoting the number of test cases.Each case contains an integerN (2 ≤ N ≤ 100).O...原创 2019-08-13 19:38:10 · 223 阅读 · 0 评论 -
Trailing Zeroes (III) (尾随零的个数) LightOJ - 1138
You task is to find minimal natural numberN, so thatN!contains exactlyQzeroes on the trail in decimal notation. As you knowN! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tr...原创 2019-08-13 16:40:13 · 108 阅读 · 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]....原创 2019-08-11 17:27:49 · 542 阅读 · 0 评论 -
Harmonic Number (II) (调和级数) LightOJ - 1245
I was trying to solve problem'1234 - Harmonic Number', I wrote the following codelonglongH(intn){ longlongres=0; for(inti=1;i<=n;i++) res=res+n/...原创 2019-08-11 17:19:58 · 212 阅读 · 0 评论 -
Prime Time UVA - 10200
Euler is a well-known matematician, and, among many other things, he discovered that the formulan 2 + n + 41 produces a prime for 0 ≤ n < 40. For n = 40, the formula produces 1681, which is 41 ∗...原创 2019-08-11 16:49:05 · 151 阅读 · 0 评论 -
Harmonic Number (调和级数)LightOJ - 1234
In mathematics, thenthharmonic number is the sum of the reciprocals of the firstnnatural numbers:In this problem, you are givenn, you have to findHn.InputInput starts with an integ...原创 2019-08-11 15:06:46 · 325 阅读 · 0 评论 -
Maximum GCD (最大公约数)
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible pair of these integers.Inputfirst line of input is an integer N (1 < N < 100) that determi...原创 2019-08-11 14:58:24 · 383 阅读 · 0 评论 -
Leading and Trailing
You are given two integers:nandk, your task is to find the most significant three digits, and least significant three digits ofnk.InputInput starts with an integerT (≤ 1000), denoting the nu...原创 2019-08-10 19:43:15 · 86 阅读 · 0 评论 -
Trailing Zeroes (II) (尾随零的个数)
Find the number of trailing zeroes for the following function: nCr* pqwheren, r, p, qare given. For example, ifn = 10, r = 4, p = 1, q...原创 2019-08-13 19:54:23 · 154 阅读 · 0 评论