![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
重新学编程之数论基础
ZZ --瑞 hopeACMer
WA就完事了
展开
-
D - Border (gcd枚举+裴蜀定理)
Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the...原创 2019-08-13 16:16:23 · 160 阅读 · 0 评论 -
E - Harmonic Number (大表)
In mathematics, thenthharmonic number is the sum of the reciprocals of the firstnnatural numbers: In this problem, you are givenn, you have to findHn. Input Input starts with an integerT...原创 2019-08-12 20:17:56 · 84 阅读 · 0 评论 -
A - LCM from 1 to n (欧拉筛+快速幂+二分查找+处理)
Given an integern, you have to find lcm(1, 2, 3, ..., n) lcmmeans least common multiple. For example lcm(2, 5, 4) = 20, lcm(3, 9) = 9, lcm(6, 8, 12) = 24. Input Input starts with an integerT (≤...原创 2019-08-12 19:43:02 · 256 阅读 · 0 评论 -
H - Pairs Forming LCM(lcm唯一分解定理+大力素数筛)
Find the result of the following code: longlongpairsFormLCM(intn){ longlongres=0; for(inti=1;i<=n;i++) for(intj=i;j<=n;j++) if( lcm(i,j) ...原创 2019-08-10 16:49:36 · 146 阅读 · 0 评论 -
G - Harmonic Number (II) (思维)
I was trying to solve problem'1234 - Harmonic Number', I wrote the following code longlongH(intn){ longlongres=0; for(inti=1;i<=n;i++) res=res+n/i; ret...原创 2019-08-10 16:07:27 · 76 阅读 · 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-08-10 15:30:26 · 109 阅读 · 0 评论 -
E - 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. Input Input starts with an integerT (≤ 1000), denoting the num...原创 2019-08-10 10:48:32 · 119 阅读 · 0 评论 -
D - Sigma Function (唯一分解定理 + 思维)
Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function actually denotes the sum of all divisors of a number. For example σ(24) = 1+2+3+4...原创 2019-08-10 10:00:35 · 132 阅读 · 0 评论 -
C - Aladdin and the Flying Carpet (唯一分解定理+约数定理)
It'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 to a magi...原创 2019-08-10 09:35:54 · 443 阅读 · 0 评论 -
A - 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...原创 2019-08-10 08:43:50 · 101 阅读 · 0 评论 -
R - 青蛙的约会(扩展欧几里得+同余)
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,...原创 2019-08-09 20:26:12 · 175 阅读 · 0 评论 -
H - Strange Way to Express Integers (扩展欧几里得+思维)
Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following: Choosekdifferent positive integersa1,a2,…,ak...原创 2019-08-13 19:16:42 · 116 阅读 · 0 评论 -
C - One Theorem, One Year (快速幂+大力素数筛+dp)
A number isAlmost-K-Primeif it has exactlyKprime numbers (not necessarily distinct) in its prime factorization. For example, 12 = 2 * 2 * 3 is anAlmost-3-Primeand 32 = 2 * 2 * 2 * 2 * 2 is anAl...原创 2019-08-12 21:19:43 · 108 阅读 · 0 评论