博文
【原创】PKU1331解题报告(源代码)(2009-01-17 14:02:00)
摘要:PKU1331代码题意:6*9 = 42" is not true for base 10, but is true for base 13. That is, 6(13) * 9(13) = 42(13) because 42(13) = 4 * 131 + 2 * 130 = 54(10).You are to write a program which inputs three integers p, q, and r and determines the base B (2<=B<=16) for which p * q = r. If there are many candidates for B, output the smallest one. For example, let p = 11, q = 11, and r = 121. Then we have 11(3) * 11(3) = 121(3) because 11(3) = 1 * 31 + 1 * 30 = 4(10) and 121(......
pku2551解题报告(2008-09-16 19:35:00)
摘要://演算除法时可以发现规律//某个数不能被n整除时,余数乘以10+1是下一个数整除n时倒数第二位的余数//以7为例// ___0_ ___1__ ___15_ ___158_ __1587_ ___15873__// 7/ 1 7/ 11 / 111 / 1111 / 11111 / 111111// /----- /----7--- /--- 7- /----7--- /---7--- / --7----// 1 &n......
PKU1019解题报告(2008-09-06 11:39:00)
摘要:PKU1019解题报告题目大意:一串数由1写道k.1 12 123 1234 12345 123456 1234567 12345678 123456789 12345678910 1234567891011初始时候k=1.写完一次后k增加1.重新从1写到k,以此循环.求这串数的第n位这串数的特征为:一个数比他的前一个数多了(int)log(10)+1位.其他完全相同第一个while()循环求出k;即k+1写完时,位数超过n.写完k时,位数不足n第二个while()循环求出i(i为1`k中的数字);要求第i+1个数写完时,位数超过n.第i个数时,位数不足n.从而求出i不知道这种方法叫什么.应该是逐步求精的思想吧.题目中使用函数log10()来求出一个数字的位数.log10在math.h 中声明:形式为_CRTIMP double __cdecl log10 (double);如果没有将其参数定义为double类型,将会编译错误.#include <iostream>#include <cstdlib>#include <math.h>using namespace std;int main(){ int t; cin>>t;//第一行输入 for(;t>0;t--) { unsigned long int n; cin>>n; unsigned long int now......
pku3302结题报告(2008-08-24 10:09:00)
摘要:pku3302结题报告水题一个题目要求:给出两个字符串,s和sub判断s是否包含了sub.包含是指s中含有sub的所有元素,并且在s中按照在sub的顺序或者逆序排列.类似于串的模式匹配问题#include <iostream>using namespace std;int main(){ char s[100]; char sub[100]; int t; int i=0,j=0,k=0; bool ok=1; int cur=0; cin>>t; for(k=0;k<t;k++) { cin>>s>>sub; int len1=strlen(s); int len2=strlen(sub); i=0;j=0; while(i<len1&&j<len2) {//正向查找  ......
pku3650解题报告(2008-08-23 22:37:00)
摘要:pku3650解题报告超级水题将几个字符替换掉" " (space) 替换成%20"!" (exclamation point) 替换成%21"$" (dollar sign) 替换成%24"%" (percent sign) 替换成%25"(" (left parenthesis) 替换成%28")" (right parenthesis) 替换成%29"*" (asterisk) 替换成%2a注意输入带空格的字符串时,可以用gets()函数获取一行.cin和scanf不行.#include <iostream>using namespace std;int main(){ char str[80]; memset(str,0,strlen(str)); while(gets(str))//获取一行输入 { if(str[0]=='#')//最后一行只有一个"#" break;//输入#时结束. else &......
PKU 1047解题报告(原创)(2008-08-18 22:29:00)
摘要:PKU 1047解题报告(原创)题目:Round and Round We Go104708-8-17题目大意:判断一个数是否为cyclic数.一个数为cyclic的条件为:设数为n位数.那么原数乘以1~n所得的结果可以通过原来的数移位得到.由于刚做完一个大数乘法的题,使用了对大数的处理方法.一次AC!比如 142857 *1 = 142857142857 *2 = 285714142857 *3 = 428571142857 *4 = 571428142857 *5 = 714285142857 *6 = 857142142857就是一个cyclic数.DescriptionA cyclic number is an integer n digits in length which, when multiplied by any integer from 1 to n, yields a"cycle"of the digits of the original number. That is, if you consider the number after the last digit to "wrap around"back to the first digit, the sequence of digits in both numbers will&nb......
