数论
cherish__lin
I want to be better!
展开
-
B. Divisors of Two Integers(思维)
Recently you have received two positive integer numbers xx and yy. You forgot them, but you remembered a shuffled list containing all divisors of xx (including 11 and xx) and all divisors of yy (inclu...原创 2019-02-14 17:21:54 · 367 阅读 · 0 评论 -
B. Preparation for International Women's Day
传送门:http://codeforces.com/problemset/problem/1133/BInternational Women's Day is coming soon! Polycarp is preparing for the holiday.There are原创 2019-03-08 19:49:19 · 758 阅读 · 0 评论 -
E - Alignment (最长上升子序列)
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his sold...原创 2019-03-08 20:33:30 · 280 阅读 · 0 评论 -
H - Eyad and Math(对数转换)
Eyad was given a simple math problem, but since he is very bad at math he asked you to help him.Given 4 numbers,a,b,c, andd. Your task is to find whetherabis less thancdor not.It is guaran...原创 2019-03-03 23:29:30 · 203 阅读 · 0 评论 -
F - Building Numbers(前缀和Or线段树)
In this problem, you can build a new number starting from 1, by performing the following operations as much as you need:Add 1 to the current number. Add the current number to itself (i.e. multiply ...原创 2019-03-04 00:20:01 · 623 阅读 · 0 评论 -
L1-046 整除光棍 (20 分)
这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1、11、111、1111等。传说任何一个光棍都能被一个不以5结尾的奇数整除。比如,111111就可以被13整除。 现在,你的程序要读入一个整数x,这个整数一定是奇数并且不以5结尾。然后,经过计算,输出两个数字:第一个数字s,表示x乘以s是一个光棍,第二个数字n是这个光棍的位数。这样的解当然不是唯一的,题目要求你输出最小的解。...原创 2019-03-15 17:12:55 · 284 阅读 · 0 评论 -
K - 素数回文(25) (素数筛+做题技巧)
xiaoou33对既是素数又是回文的数特别感兴趣。比如说151既是素数又是个回文。现在xiaoou333想要你帮助他找出某个范围内的素数回文数,请你写个程序找出 a 跟b 之间满足条件的数。(5 <= a < b <= 100,000,000);Input这里有许多组数据,每组包括两组数据a跟b。Output对每一组数据,按从小到大输出a,b之间所有满足条件的素数...原创 2019-03-15 19:19:08 · 346 阅读 · 0 评论 -
F - Divisibility POJ - 1745
Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let ...原创 2019-03-08 09:36:11 · 196 阅读 · 0 评论 -
L1-006 连续因子 (20 分)(简单模拟)
L1-006连续因子(20 分)一个正整数N的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。输入格式:输入在一行中给出一个正整数N(1<N<231)。输出格式:首先在第 1 行输出最长连续因子的个数;然...原创 2019-03-13 08:45:48 · 6738 阅读 · 0 评论 -
C. Edgy Trees(并查集+数学)
You are given a tree (a connected undirected graph without cycles) ofnnvertices. Each of then−1n−1edges of the tree is colored in either black or red.You are also given an integerkk. Consider s...原创 2019-03-22 07:42:41 · 374 阅读 · 0 评论 -
B. Nirvana
Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits...原创 2019-04-03 18:08:13 · 522 阅读 · 1 评论 -
K - Wand(组合数+错排公式)
N wizards are attending a meeting. Everyone has his own magic wand. N magic wands was put in a line, numbered from 1 to n(Wand_i owned by wizard_i). After the meeting, n wizards will take a wand one b...原创 2019-04-12 23:02:33 · 339 阅读 · 0 评论 -
R - Race to 1 (期望)
Dilu have learned a new thing about integers, which is - any positive integer greater than 1 can be divided by at least one prime number less than or equal to that number. So, he is now playing with t...原创 2019-04-20 23:08:33 · 272 阅读 · 0 评论 -
P - A Dangerous Maze (II) (期望)
You are in a maze; seeingndoors in front of you in beginning. You can choose any door you like. The probability for choosing a door is equal for all doors.If you choose theithdoor, it can either...原创 2019-04-20 23:35:47 · 228 阅读 · 0 评论 -
C. Problem for Nazar(奇偶性质)
Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him avery difficult task.Consider two infinite s...原创 2019-04-19 23:22:17 · 375 阅读 · 0 评论 -
I - Interesting Numbers URAL - 2070
Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a prime number. However, Asya thinks an integer is interesting if the amount of it...原创 2019-04-24 19:24:25 · 238 阅读 · 0 评论 -
根的存在性定理(二分法)
#include<iostream>#include<cmath>#include<iomanip>using namespace std;double f(double x){ return x*x-3*x+1;}const double e=1e-9;int main(){ double a,b,x; cin>...原创 2019-02-27 13:34:03 · 1736 阅读 · 0 评论 -
Recursive sequence(矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 Problem Description Farmer John likes to play mathematics games with his N cows. Recently, they are attracted by recursive sequences. I...原创 2019-02-26 23:49:50 · 282 阅读 · 0 评论 -
C - A mid-summer night's dream. (中位数的性质)->UVA - 10057
Problem CA mid-summer night’s dreamInput:standard inputOutput:standard outputThis is year 2200AD. Science has progressed a lot in two hundred years. Two hundred years is mentioned here be...原创 2019-03-06 08:59:25 · 266 阅读 · 0 评论 -
N - Trailing Zeroes (III)(二分查找)
You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tra...原创 2019-02-21 15:39:43 · 135 阅读 · 0 评论 -
E - 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.InputInput starts with an integer T (≤ 1000), denoting the ...原创 2019-02-21 17:43:38 · 264 阅读 · 0 评论 -
H - Biorhythms (中国剩余定理)
Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods ...原创 2019-02-21 23:07:57 · 181 阅读 · 0 评论 -
R - 青蛙的约会 (裸的扩展欧几里得)
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,...原创 2019-02-22 10:57:07 · 124 阅读 · 0 评论 -
G - Harmonic Number (II)
I was trying to solve problem '1234 - Harmonic Number', I wrote the following codelong long H( int n ) { long long res = 0; for( int i = 1; i <= n; i++ ) res = res + n / i; ret...原创 2019-02-22 13:40:36 · 156 阅读 · 0 评论 -
F - 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-02-22 15:42:31 · 657 阅读 · 0 评论 -
V - Maximum GCD(读入技巧)
Given the N integers, you have to nd the maximum GCD (greatest common divisor) of every possiblepair of these integers.InputThe rst line of input is an integerN(1<N<100) that determines th...原创 2019-02-22 16:54:23 · 252 阅读 · 0 评论 -
L - Fantasy of a Summation (全排列+快速幂+快速乘)
If you think codes, eat codes then sometimes you may get stressed. In your dreams you may see huge codes, as I have seen once. Here is the code I saw in my dream.#include <stdio.h>int cases, c...原创 2019-02-22 18:02:36 · 352 阅读 · 0 评论 -
B - 233 Matrix(矩阵快速幂)
In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. I...原创 2019-02-18 15:35:16 · 263 阅读 · 0 评论 -
因式分解
Problem Description将大于1的自然数N进行因式分解,满足N=a1*a2*a3…*am。编一程序,对任意的自然数N(1< N<=2,000,000,000),求N的所有形式不同的因式分解方案总数。如N=12,共有8种分解方案,他们分别是: 12=12 12=6*2 12=4*3 12=3*4 12=3*2*2 12=2*6 12=2*3*2 12=...原创 2019-02-23 22:02:34 · 492 阅读 · 1 评论 -
C - A Short problem(矩阵快速幂)
According to a research, VIM users tend to have shorter fingers, compared with Emacs users. Hence they prefer problems short, too. Here is a short one: Given n (1 <= n <= 10 18), You should ...原创 2019-02-18 18:30:47 · 196 阅读 · 0 评论 -
D - K-based Numbers. Version 3 (矩阵快速幂+dp)
Let’s consider K-based numbers, containing exactly N digits. We define a number to be valid if its K-based notation doesn’t contain two successive zeros. For example:1010230 is a valid 7-digit numbe...原创 2019-02-24 21:42:14 · 145 阅读 · 0 评论 -
E - Sasha and Array(线段树+矩阵快速幂)
Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types:1 l r x — increase all integers on the segment from l to r by values x; 2 l r — fi...原创 2019-02-19 13:56:06 · 399 阅读 · 0 评论 -
A. Design Tutorial: Learn from Math (拆合数)
题目链接:http://codeforces.com/problemset/problem/472/AOne way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build ...原创 2019-02-25 17:36:54 · 220 阅读 · 0 评论 -
B. Tanya and Candies (简单模拟)
题目链接:http://codeforces.com/contest/1118/problem/BTanya has nn candies numbered from 11 to nn. The ii-th candy has the weight aiai.She plans to eat exactly n−1n−1 candies and give the remaining can...原创 2019-02-20 23:08:00 · 634 阅读 · 0 评论 -
E - A New Function LightOJ - 1098
We all know that any integer number n is divisible by 1 and n. That is why these two numbers are not the actual divisors of any numbers. The function SOD(n) (sum of divisors) is defined as the summati...原创 2019-05-22 19:35:02 · 286 阅读 · 0 评论