cjweffort

博客园 首页 联系 订阅 管理

2013年3月6日

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=60题目描述:输入一个正整数N,输出N的阶乘。输入:正整数N(0 #include const int N=1003; int aa[N]; int size; void mul(int n) { int in=0; for(int i=0;i=0;i--) printf("%04d",aa[i]); printf("\n"); } int main() { int n; while(scanf("%d",&n)!=EOF) { 阅读全文
posted @ 2013-03-06 11:41 cjweffort 阅读(175) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=59题目描述:实现一个加法器,使其能够输出a+b的值。输入:输入包括两个数a和b,其中a和b的位数不超过1000位。输出:可能有多组测试数据,对于每组数据,输出a+b的值。样例输入:2 6 10000000000000000000 10000000000000000000000000000000样例输出:8 10000000000010000000000000000000// 题目60:a+b.cpp: 主项目文件。 #include "stdafx.h" #include # 阅读全文
posted @ 2013-03-06 11:40 cjweffort 阅读(170) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=58题目描述:A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973。输入:数据的第一行是一个T,表示有T组数据。每组数据的第一行有n(2 #include const int N=12; int n; struct Matrix { int arr[N][N]; }; /*Matrix init(Matrix mat) { Matrix res; for(int i=1;i>1); Matrix res=multiply(tmp1,tmp1); ... 阅读全文
posted @ 2013-03-06 11:39 cjweffort 阅读(143) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=57题目描述:Xinlv wrote some sequences on the paper a long time ago, they might be arithmetic or geometric sequences. The numbers are not very clear now, and only the first three numbers of each sequence are recognizable. Xinlv wants to know some numbers i 阅读全文
posted @ 2013-03-06 11:39 cjweffort 阅读(135) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=56题目描述:求A^B的最后三位数表示的整数。说明:A^B的含义是“A的B次方”输入:输入数据包含多个测试实例,每个实例占一行,由两个正整数A和B组成(1 int pow(int a,int n) { if(n==1) return a; int res=1; if(n&0x01) res=a%1000; int tmp=pow(a,n>>1); res=(res*((tmp*tmp)%1000))%1000; return res; } int main(array ^arg 阅读全文
posted @ 2013-03-06 11:36 cjweffort 阅读(160) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=55题目描述:输入n个整数,依次输出每个数的约数的个数输入:输入的第一行为N,即数组的个数(N #include #include const int N=31650; bool prime[N]; void selectPrime() { memset(prime,0,sizeof(prime)); prime[0]=prime[1]=true; for(int i=2;i<N;i++) { if(!prime[i]) { for(int j=i+i;j<N;j+=i) ... 阅读全文
posted @ 2013-03-06 11:35 cjweffort 阅读(232) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=54题目描述:给定n,a求最大的k,使n!可以被a^k整除但不能被a^(k+1)整除。输入:两个整数n(2 #include #include const int N=1001; bool prime[N]; int base_n[N]; int base_a[N]; void selectPrime() { memset(prime,0,sizeof(prime)); prime[0]=prime[1]=true; for(int i=2;i<N;i++) { if(!prime[i... 阅读全文
posted @ 2013-03-06 11:34 cjweffort 阅读(165) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=53题目描述:求正整数N(N>1)的质因数的个数。相同的质因数需要重复计算。如120=2*2*2*3*5,共有5个质因数。输入:可能有多组测试数据,每组测试数据的输入是一个正整数N,(1 #include const int N=31650; bool used[N]; void selectPrime() { memset(used,0,sizeof(used)); used[0]=used[1]=true; for(int i=2;i<N;i++) { if(!used[i]) . 阅读全文
posted @ 2013-03-06 11:33 cjweffort 阅读(275) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=52题目描述:Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2.This conjecture has not been proved nor refused yet. No one is sure whether this conjec 阅读全文
posted @ 2013-03-06 11:32 cjweffort 阅读(153) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=51题目描述:Output the k-th prime number.输入:k≤10000// 题目52:Prime Number.cpp: 主项目文件。 #include "stdafx.h" #include #include const int N=104733; bool used[N]; const int M=10003; int prime[M]; int selectePrime(int n) { memset(used,0,sizeof(used)); in 阅读全文
posted @ 2013-03-06 11:31 cjweffort 阅读(163) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=50题目描述:输入一个整数n(2 #include bool isPrime(int n) { if(n<=1) return false; int tt=(int)sqrt(1.0*n); for(int i=2;i<=tt;i++) if(n%i==0) return false; return true; } int main() { int n; while(scanf("%d",&n)!=EOF) { bool flag=true; for(int 阅读全文
posted @ 2013-03-06 11:30 cjweffort 阅读(182) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=49题目描述:给定一个数n,要求判断其是否为素数(0,1,负数都是非素数)。输入:测试数据有多组,每组输入一个数n。输出:对于每组输入,若是素数则输出yes,否则输入no。样例输入:13// 题目50:素数判定.cpp: 主项目文件。 #include "stdafx.h" #include #include bool isPrime(int n) { if(n<=1) return false; int tt=(int)sqrt(1.0*n); for(int i=2; 阅读全文
posted @ 2013-03-06 11:30 cjweffort 阅读(239) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=48题目描述:The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.输入:Input will consist of multiple problem instances. The 阅读全文
posted @ 2013-03-06 11:29 cjweffort 阅读(151) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=47题目描述:给定两个正整数,计算这两个数的最小公倍数。输入:输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数。输出:对于每个测试用例,给出这两个数的最小公倍数,每个实例输出一行。样例输入:10 14样例输出:70// 题目47:最大公约数.cpp: 主项目文件。 #include "stdafx.h" #include long long lcm(long long a,long long b) { long long ta=a,tb=b; if(a< 阅读全文
posted @ 2013-03-06 11:27 cjweffort 阅读(187) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=46题目描述:输入两个正整数,求其最大公约数。输入:测试数据有多组,每组输入两个正整数。输出:对于每组输入,请输出其最大公约数。样例输入:49 14样例输出:7// 题目47:最大公约数.cpp: 主项目文件。 #include "stdafx.h" #include long long lcm(long long a,long long b) { long long ta=a,tb=b; if(a<b) { long long tmp; tmp=a;a=b;b=tmp; 阅读全文
posted @ 2013-03-06 11:25 cjweffort 阅读(205) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=45题目描述:输入一个整数,将其转换成八进制数输出。输入:输入包括一个整数N(0 void transmit(int num) { if(num==0) { printf("0\n"); return; } int arr[10],cnt=0; while(num) { arr[cnt++]=num%8; num/=8; } for(int i=cnt-1;i>=0;i--) printf("%d",arr[i]); printf("\n&q 阅读全文
posted @ 2013-03-06 11:24 cjweffort 阅读(226) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=44题目描述:将一个长度最多为30位数字的十进制非负整数转换为二进制数输出。输入:多组数据,每行为一个长度不超过30位的十进制非负整数。(注意是10进制数字的个数可能有30个,而非30bits的整数)输出:每行输出对应的二进制数。样例输入:0 1 3 8样例输出:0 1 11 1000// 题目45:进制转换.cpp: 主项目文件。 #include "stdafx.h" #include #include struct bigInt { char str[203]; void 阅读全文
posted @ 2013-03-06 11:22 cjweffort 阅读(176) 评论(0) 推荐(0) 编辑

摘要: 题目描述: 求任意两个不同进制非负整数的转换(2进制~16进制),所给整数在long所能表达的范围之内。 不同进制的表示符号为(0,1,...,9,a,b,...,f)或者(0,1,...,9,A,B,...,F)。输入: 输入只有一行,包含三个整数a,n,b。a表示其后的n 是a进制整数,b表示欲将a进制整数n转换成b进制整数。a,b是十进制整数,2 = int toShi(char *str,int a) { int sum=0; for(int i=0;str[i];i++) { if(str[i]>='A'&&str[i]='a'& 阅读全文
posted @ 2013-03-06 11:21 cjweffort 阅读(217) 评论(0) 推荐(1) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=42题目描述:输入两个不超过整型定义的非负10进制整数A和B( void aPlusB(unsigned int sum,int k) { if(sum==0) { printf("0\n"); return; } int arr[50],cnt=0; while(sum) { arr[cnt++]=sum%k; sum/=k; } for(int i=cnt-1;i>=0;i--) printf("%d",arr[i]); printf(" 阅读全文
posted @ 2013-03-06 11:20 cjweffort 阅读(128) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=41题目描述: The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and 阅读全文
posted @ 2013-03-06 11:19 cjweffort 阅读(141) 评论(0) 推荐(0) 编辑