随笔分类 -  大数

摘要:1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define N 1005 5 using namespace std; 6 7 int StrToNum(char t)//字符--->>数字 8 { 9 if(t>='0'&&t<='9')return t-'0';//数字10 if(t>='A'&&t<='Z')return t-& 阅读全文
posted @ 2012-08-22 14:35 疼痛落在指尖 阅读(293) 评论(0) 推荐(0) 编辑
摘要:1 /*大数取余-------mod 为 (int范围)*/ 2 /* 具体做法: 3 从大数最高位开始,只要其大于mod 4 就实行取余,一直下去,最终得到余数 5 例如:123 % 4 取一个中间变量t=0 6 1<4 t=1 7 --- 2 t=1*10+2=12>4 t=t%4=0 8 --- 3 t=0+3=3 t=t%4=3 9 -------------------- 余数 310 */11 #include<iostream>12 #include<string>13 #inc... 阅读全文
posted @ 2012-08-22 14:33 疼痛落在指尖 阅读(1227) 评论(0) 推荐(0) 编辑
摘要:1 //形如2n-1的素数称为麦森数,这时n一定也是个素数。但反过来不一定,即如果n是个素数。2n-1不一定也是素数。 2 3 #include<iostream> 4 #include<cmath> 5 #include<cstdio> 6 #include<cstring> 7 #define N 126 8 using namespace std; 9 int ans[N],anspow[N];10 void mult(int ans[],int anspow[])11 {12 int i,j;13 int c[N];14 memset(c 阅读全文
posted @ 2012-08-22 14:29 疼痛落在指尖 阅读(208) 评论(0) 推荐(0) 编辑
摘要:1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int n; 6 while(cin>>n) 7 { 8 while(n--) 9 {10 int m,flags=0;11 cin>>m;12 while(m!=1)13 {14 if(m%2)15 {16 if(... 阅读全文
posted @ 2012-08-22 13:19 疼痛落在指尖 阅读(167) 评论(0) 推荐(0) 编辑
摘要:1 //斯特林公式: 2 #include<iostream> 3 #include<cmath> 4 using namespace std; 5 int n; 6 #define e 2.7182818284590452354 7 #define PI 3.141592653589793239 8 int main() 9 {10 int t,des;11 double i,sum;12 scanf("%d",&t );13 while(t-- )14 {15 scanf("%d",&n);16 if(n< 阅读全文
posted @ 2012-08-22 13:09 疼痛落在指尖 阅读(346) 评论(0) 推荐(0) 编辑
摘要:1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 int a[21]={0,1}; 5 int main() 6 { 7 int n; 8 double m,l,des; 9 while(~scanf("%d",&n))10 {11 for(int i=2;i<=20;i++)12 {13 a[i]=a[i-1]+a[i-2];14 }15 if(n<=20)printf("%d\n",a[n])... 阅读全文
posted @ 2012-08-22 12:51 疼痛落在指尖 阅读(175) 评论(0) 推荐(0) 编辑
摘要:/*求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1<=A,B<=10000),如果A=0, B=0,则表示输入数据的结束,不做处理。对于每个测试实例,请输出A^B的最后三位表示的整数,每个输出占一行。2 312 66789 100000 089841*///思路:当幂集超过6位之后对1000求余值不变。#include<iostream>using namespace std;int main(){int a,b;while(cin>>a>>b){if(a== 阅读全文
posted @ 2012-07-27 08:47 疼痛落在指尖 阅读(184) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示