数论
我要去看得最远的地方
要把自己活成一束光,自信坦荡,光芒万丈,不卑不亢,不慌不忙,不羡慕谁,不依赖谁。抬头所见即是温柔。
展开
-
无重复字符的最长子串
力扣,滑动窗口原创 2023-03-05 22:09:09 · 50 阅读 · 0 评论 -
super_log(欧拉降幂)
题意:就是给你a,b,m求a^a^a^a^a....(b个a)%m的大小。题解:首先看欧拉函数:1.欧拉函数:小于或等于n且与n互素的正整数个数,称为欧拉函数。代码中是phi()函数2.若n的质因数为p1,p2,p3,,,,,pn,则欧拉函数phi(n)可以表示为phi(n)=n*(1-1/p1)*(1-1/p2)*(1-1/p3)*.....(1-1/pn).3.如果p是一个素数...原创 2019-09-03 21:36:07 · 316 阅读 · 0 评论 -
X问题
Problem Description求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod a[i] = b[i], … (0 < a[i] <= 10)。Input输入数据的第一行为一个正整数T,表示有T组测试数据。每组测试数据的第一行为两个正...原创 2019-08-15 20:54:33 · 163 阅读 · 0 评论 -
Hello Kiki(中国剩余定理不互质)
自己写总是有点问题,当n==1时,且a[i]=0(余数)时应该返回m[0];这应该注意Problem DescriptionOne day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running and singing "门前大桥下...原创 2019-08-15 20:51:12 · 199 阅读 · 0 评论 -
UVA - 10791
题意 :求解一组数(至少两个数)的LCM为n,问符合这个答案的一组数和的最小值题解:质因子分解,各个质因子^个数的和,有些细节需要处理,详情见代码#include<stdio.h>#include<map>#include<algorithm>#define maxn 1000100using namespace std;typedef lo...原创 2019-08-09 20:50:18 · 195 阅读 · 0 评论 -
LightOJ - 1341(算术基本原理)
题解:需要素数打表否则会超时。。。。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 abou...原创 2019-08-09 18:53:14 · 273 阅读 · 0 评论 -
算术基本定理
算术基本定理,又称为正整数的唯一分解定理,即:每个大于1的自然数均可写为质数的积,而且这些素因子按大小排列之后,写法仅有一种方式。例如:90=2*3^2*5(pi是质数且ri>=0)代码实现:复杂度: #include<stdio.h>#include<algorithm>#include<map>using namespace s...原创 2019-08-05 10:54:32 · 3620 阅读 · 0 评论 -
XOR Permutations
A bitwise XOR takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of corresponding bits. The result in each position is11if both bits are different (o...原创 2019-05-06 00:13:40 · 342 阅读 · 0 评论 -
I - Array Negations Gym - 102152I
You are given an arrayaaofnnintegers, and an integerkk. You have to makekknegation operations such that at each operation you need to choose an elementaiaifrom the array and replace it with−ai...原创 2019-05-02 09:49:46 · 671 阅读 · 0 评论 -
B - Bin & Jing in wonderland(FZU - 2103组合数学 )
题意:就是有n种礼物,然后可以选取K个,但是你想得到ID比较大的r个,现在给出了你选取的ID号,让你求得到此序列概率。题解:就是把你已经选取的r个,令L=最小的ID,,此时要把1到L-1看成一个整体来计算,然后枚举L可以有的个数,L到N就按照排列组合计算就行。(此时要把1到L-1看成一个整体来计算)这里你思考一下就会懂我举个例子假如 l=3, 1的概率为0.3,2的概率为0.4,...原创 2019-04-09 00:01:50 · 138 阅读 · 0 评论 -
整除光棍
#include<stdio.h>int main(){ int x; scanf("%d",&x); long long sum=1; int t=1; while(sum<x) { sum=sum*10+1; t++; } int flag=0; while(1) { printf("%d",sum/x); sum=su...原创 2019-03-28 23:13:43 · 85 阅读 · 0 评论 -
Pseudoprime numbers(poj3641)
题意:就是素数p能够满足a^p%p=a%p,但是有些合数p也满足这个公式,这样的合数被称为伪素数,判断p相对于给定的a是否为伪素数。解题思路:如果p为素数直接输出no,否则判断a^p%p=a%p是否成立,如果成立输出yes,否则no.Fermat’s theorem states that for any prime number p and for any integer a>1,...原创 2019-02-27 00:00:15 · 138 阅读 · 0 评论 -
X-factor Chains(poj3421)(素数因子)
题解:就是给你一个正整数,然后你求出他的因字串从小到大排列的最大长度,以及这个最大长度的种类数所以就找所有的素数因子,素数因子数即为最大长度数,然后就是,这几个因字数的全排列,即为种类数(注意有重复因子,这就用到数学知识了,需要去重) Language:Default X-factor Chains Time Limit: 1000MS ...原创 2019-02-26 18:14:16 · 260 阅读 · 0 评论 -
小数第n位 (蓝桥杯简单的除法运算)
问题描述 我们知道,整数做除法时,有时得到有限小数,有时得到无限循环小数。 如果我们把有限小数的末尾加上无限多个0,它们就有了统一的形式。 本题的任务是:在上面的约定下,求整数除法小数点后的第n位开始的3位数。输入格式 一行三个整数:a b n,用空格分开。a是被除数,b是除数,n是所求的小数后位置(0<a,b,n<1000000000)输出格式 一行...原创 2019-02-28 19:29:26 · 378 阅读 · 0 评论