![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数学
狠人王
怀着一颗热情的心,追随自己的梦想!
展开
-
【51nod】最大公约数之和(欧拉函数)
http://www.51nod.com/Challenge/Problem.html#problemId=1040本题给出1个n,要你求1-n每个数和n的最大公约数之和每一个最大公约数即为n的因子,设为k,所以gcd(i,n)=k,可以转化为gcd(i/k,n/k)=1;而这个式子可以通过欧拉函数求出,利用试除法枚举因子。#include<iostream>usin...原创 2019-10-22 21:06:41 · 361 阅读 · 0 评论 -
【51nod】1010 只包含因子2 3 5的数(数学)
http://www.51nod.com/Challenge/Problem.html#problemId=1010打表+二分#include<iostream>#include<algorithm>using namespace std;typedef long long ll;const ll maxn=1e18+2;ll a[1000000];l...原创 2019-10-21 21:24:07 · 122 阅读 · 0 评论 -
【codeforce】C. Common Divisors(数学)
http://codeforces.com/contest/1203/problem/C题意是让我们找到一串数的所有因子思路:找到这串数的最大公约数(gcd),枚举最大公约数的因子用for循环写的试除法居然会T,改为while就过,但是估计的复杂度一模一样,需要额外注意的是完全平方数的中间因子即为1个#include<iostream>using namespace...原创 2019-10-20 10:43:42 · 139 阅读 · 0 评论 -
勾股数
#include <cstdio>#include <cstdlib>#include <cctype>#include <cstring>#include <string>#include <cmath>#include <algorithm>#include <iostream>t...原创 2019-09-22 10:36:05 · 225 阅读 · 0 评论 -
Comet OJ - Contest #11 eon
对于一个数n,记 m为把n的各数位重排序得到的最大的数,求m-n对10取模的值(也就是m−n除以10的余数)。举例来说,当n = 213时, 各数位重排序有123、132、213、231、312、321六种可能,其中最大的数字是321,所以m=321,输出的答案即为(m-n) = 108对10取模的结果,也就是8;input:一行...原创 2019-09-21 19:44:11 · 219 阅读 · 0 评论 -
C. Book Reading(数学规律)
Polycarp is reading a book consisting of n pages numbered from 1 to n. Every time he finishes the page with the number divisible by m, he writes down the last digit of this page number. For example, i...原创 2019-09-19 17:39:50 · 261 阅读 · 0 评论 -
数论逆元
1 什么是逆元 2 存在逆元的条件是什么 3 怎样求一个数的逆元 1.[ 欧几里得扩展] 2. 费马小定理 (最常用) 4 扩展(常用) 1. 线性逆元(常用) 2 快速阶乘逆元(常用)逆元是数论之中的一个重要概念参考博客 ACdre...转载 2019-08-10 10:26:12 · 317 阅读 · 0 评论 -
【51nod】1013 3的幂的和(乘法逆元)(费马小定理)(快速幂)
问题:求:3^0 + 3^1 +…+ 3^(N) mod 1000000007输入输入一个数N(0 <= N <= 10^9)输出输出:计算结果输入样例3输出样例40分析:考察快速幂,费马小定理除法运算(除法取模只需将除法变乘法,相当于被除数乘以除数的乘法逆元),等比数列求和公式,#include <iostream>using namespace ...原创 2019-08-07 10:22:18 · 123 阅读 · 0 评论 -
【51nod】 2652 阶乘0的数量 V2(数学)(二分)
Description给出一个数k,求最小的n,使得n的阶乘后面0的数量>=k。例如k=1,5的阶乘 = 12345 = 120,120后面有1个0。并且4的阶乘后面没有0,所以5是最小的结果。输入一个数k(1 <= k <= 10^9)输出输出最小的满足条件的n。输入样例1输出样例5题意:题目中说的已经很明白了,就是要解决某个数的阶乘后面零的个数和查询...原创 2019-08-06 16:10:18 · 687 阅读 · 0 评论 -
D - D CodeForces - 225E Unsolvable(梅森素数)
数学题科普:森素数是由梅森数而来。所谓梅森数,是指形如2p-1的一类数,其中指数p是素数,常记为Mp 。如果梅森数是素数,就称为梅森素数。用因式分解法可以证明,若2n-1是素数,则指数n也是素数;反之,当n是素数时,2n-1(即Mp)却未必是素数。前几个较小的梅森数大都是素数,然而梅森数越大,梅森素数也就越难出现。题面:Consider the following equation:...原创 2019-07-28 15:53:56 · 207 阅读 · 0 评论 -
LightOJ Circle in Square (简单计算几何)
A circle is placed perfectly into a square. The term perfectly placed means that each side of the square is touched by the circle, but the circle doesn’t have any overlapping part with the square. See...原创 2019-08-01 15:52:35 · 277 阅读 · 0 评论 -
CodeForces-233B(简单数学求根)
Let’s consider equation:x2 + s(x)·x - n = 0,where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.You are given an integer n, f...原创 2019-07-31 21:35:44 · 237 阅读 · 0 评论 -
HDU5646 DZY Loves Partition(二分)
DescriptionDZY loves partitioning numbers. He wants to know whether it is possible to partition n into the sum of exactly k distinct positive integers.After some thinking he finds this problem is To...原创 2019-08-04 17:00:27 · 186 阅读 · 0 评论 -
快速乘
通过例题看一下就行了例:64位整数乘法求a乘b对p取模的值,1<=a,b,p<=10^18.看这庞大的数据量就知道肯定不能直接去求,可以利用快速幂思想,即二进制展开结合位运算提高计算的效率。#include<iostream>#include<cstdio>#include<cmath>using namespace std;typ...原创 2019-07-23 16:10:38 · 98 阅读 · 0 评论