PAT1058 A+B in Hogwarts

题目:PAT1058

题解:模拟加法和注意进位就行

代码:

 1 #include<cstdio>
 2
 3 using namespace std;
 4
 5 int a1,b1,c1,a2,b2,c2;
 6
 7 int main()
 8 {
 9     scanf("%d.%d.%d %d.%d.%d",&a1,&b1,&c1,&a2,&b2,&c2);
10
11     c1+=c2;
12
13     b1+=b2;
14     b1+=(c1/29);
15
16     c1%=29;
17
18     a1+=a2;
19     a1+=(b1/17);
20
21     b1%=17;
22
23     printf("%d.%d.%d",a1,b1,c1);
24
25     return 0;
26
27 }
时间: 2024-10-16 21:44:35

PAT1058 A+B in Hogwarts的相关文章

pat1058. A+B in Hogwarts (20)

1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 Sickle

1058. A+B in Hogwarts

1058. A+B in Hogwarts (20) 时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue 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 Sickle

pat 1058 A+B in Hogwarts(20 分)

1058 A+B in Hogwarts(20 分) 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.

PAT甲级水题 A+B in Hogwarts(java string中分隔符的用法)

A+B in Hogwarts 在java.lang包中有String.split()方法,返回是一个数组 我在应用中用到一些,给大家总结一下,仅供大家参考: 1.如果用"."作为分隔的话,必须是如下写法,String.split("\\."),这样才能正确的分隔开,不能用String.split("."); 2.如果用"|"作为分隔的话,必须是如下写法,String.split("\\|"),这样才能正确

1058 A+B in Hogwarts (20 分)

1058 A+B in Hogwarts (20 分) 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

PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)

1058 A+B in Hogwarts (20 分)   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 enou

1058 A+B in Hogwarts (20分)

1058 A+B in Hogwarts (20分) 题目: 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 eno

1058 A+B in Hogwarts (20)

1 #include <stdio.h> 2 int main() 3 { 4 int ans1[3]; 5 int ans2[3]; 6 while(scanf("%d.%d.%d %d.%d.%d",&ans1[0],&ans1[1],&ans1[2],&ans2[0],&ans2[1],&ans2[2])!=EOF) 7 { 8 ans1[0]+=ans2[0]; 9 ans1[1]+=ans2[1]; 10 ans1[

PAT:1058. A+B in Hogwarts (20) AC

#include<stdio.h> #include<stdlib.h> int main() { int a1,b1,c1,a2,b2,c2; //[思维]168以内的数字可以用两位13进制数表示,大大简化代码 scanf("%d.%d.%d",&a1,&b1,&c1); scanf("%d.%d.%d",&a2,&b2,&c2); int ra,rb,rc,tmp; //ra,rb,rc存放