cjweffort

博客园 首页 联系 订阅 管理
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页

2013年3月6日

摘要: 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 阅读(204) 评论(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 阅读(214) 评论(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) 编辑

2013年3月5日

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=40题目描述:打印所有不超过n(n bool isDui(int n) { int res=n*n; int arrA[11]; int cntA=0; while(res) { arrA[cntA++]=res%10; res/=10; } for(int i=0,j=cntA-1;i<=j;i++,j--) if(arrA[i]!=arrA[j]) return false; return true; } int main() { freopen("F:\\ou... 阅读全文
posted @ 2013-03-05 11:35 cjweffort 阅读(206) 评论(0) 推荐(0) 编辑

上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页