1058 A+B in Hogwarts (20 point(s))
If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough." Your job is to write a program to compute A+B where A and B are given in the standard form of Galleon.Sickle.Knut
(Galleon
is an integer in [0,107], Sickle
is an integer in [0, 17), and Knut
is an integer in [0, 29)).
Each input file contains one test case which occupies a line with A and B in the standard form, separated by one space.
For each test case you should output the sum of A and B in one line, with the same format as the input.
3.2.1 10.16.27
14.1.28
题目大意:自定义一个结构的运算,实现这个运算。a.b.c这样一个结构,第一个数范围是0到10的七次方,b是17,c是29
进位搞一下。
解题思路:水是很水,但我还是WA了一发,不知道为什么,第一个数范围明明是有限制的,为什么不考虑溢出的,我现在也不是很懂为什么错。。反正不考虑溢出就对了。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
1059 Prime Factors (25 point(s))
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.
Each input file contains one test case which gives a positive integer N in the range of long int.
Factor N in the format N =
p1^
k1*
p2^
k2*
…*
pm^
km, where pi's are prime factors of N in increasing order, and the exponent ki is the number of pi -- hence when there is only one pi, ki is 1 and must NOT be printed out.
97532468
97532468=2^2*11*17*101*1291
题目大意:实现一下质因数分解。
解题思路:其实一开始看到这题目脑子里出现的就是打表了。。毕竟运行时间是在你进行输入后开始计算的是吧。后来又想了一下。。long int 能分解的质数最大也就10位吧,直接一个个判断上去不就行了,还搞什么素数判定,直接从2开始分解,不可能存在整除不是质因子的结果呀。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include