随笔分类 - 数学
摘要:#include<iostream> #include<string> #include<string> #include<string.h> #include<stdio.h> #include<queue> #include<math.h> #include<vector> #include<s
阅读全文
摘要:这道题目细节琐碎,稍不注意就会WA ,特别是大数的范围,一开始没有把n声明为long long 导致最大的那个数 2147483647 结果为0 还有一开始用了 pow() 这个函数,也应该用double去接受结果。 #include<iostream> #include<string> #incl
阅读全文
摘要:一看四个整数的范围,<=10000 所以我们肯定不能直接打表求阶乘 利用唯一分解定理(任何一个大于1的正整数都能够被唯一地分解成质因子乘积) #include<iostream> #include<string> #include<string> #include<string.h> #includ
阅读全文
摘要:#include<iostream> #include<string> #include<string> #include<string.h> #include<stdio.h> #include<queue> #include<math.h> #include<vector> #include<s
阅读全文
摘要:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=2629&mosmsg=Submission+received+with+ID+1697
阅读全文
摘要:输入正整数 a,n,m 输出 a^n %m 的值 #include<iostream> #include<string> #include<string> #include<string.h> #include<stdio.h> #include<stdlib.h> using namespace
阅读全文
摘要:输入正整数n,m n<=pow(10,100),m<=pow(10,9) 输出 n%m 想想我们在算除法时的过程,我们可以模拟那个过程. #include<iostream> #include<string> #include<string.h> #include<stdio.h> #include
阅读全文
摘要:做这个题目之前有必要好好了解一下浮点数的有关知识,怎样将浮点数转换为十进制形式,以及怎样将十进制形式转化为浮点数整个32位分为3部分:sign:符号位,1 bit,0为正,1 为负Exponent(bias):指数部分 8 bits 存储格式为移码存储,偏移量为127Mantissa(fractio...
阅读全文
摘要:牛顿迭代#include#include#includeusing namespace std;float f(float x){ return (pow(x,3)-5*pow(x,2)+16*x+80);}float f1(float x){ return (3*pow(x,2)-5*...
阅读全文
摘要:1、整数的快速幂a^b%m当b还不是很大的时候(a%m)……%mint mod(int a,int b,int m){ int ans=1,i; for(i=1;i<=b;i++){ ans=ans*a%m; } return ans;}但是a,b太大可能存不下...
阅读全文
摘要:扩展欧几里德 1、求解不定方程(ax+by=c,已知x,y,c,求a,b) 2、求解模的线性同余方程( axΞb(mod m) 对于未知数x的求解) 3、求模的逆元 axΞ1(mod m) 此时的x称为a的对模m乘法的逆元)1、求解不定方程:ax+by=cax0+by0=gcd(a,b);ax0*c...
阅读全文
摘要:求一个数有N多少位,可用log10(N)+1,于是,求N!有多少位 log10(1*2*3*……*n)=log10(1)+log10(2)+……+log10(N)+1#include#includeusing namespace std;int main(){ int n,i,m,j; ...
阅读全文
摘要:#include#includeusing namespace std;int main(){ int n; while(cin>>n){ int i,j,k=0,a[10000]; a[0]=1; for(i=1;i=0;i--) ...
阅读全文
摘要:#includeusing namespace std;int a[20000],label[5000];//素数筛选int main(){ int n,max,j,t; while(cin>>n){ max=-1; for(int i=0;i>label[i...
阅读全文
摘要:int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}欧几里得欧几里得算法使计算两个数的最大公约数的传统算法,无论从理论还是效率上都是很好的算法。然而,当所给定的整数超出了计算机的表示能力,则计算过程就需要由用户来专...
阅读全文

浙公网安备 33010602011771号