PAT-A1058 A+B in Hogwarts (20)(模拟)
来源:互联网 发布:网络打印机搜索不到 编辑:程序博客网 时间:2024/06/14 02:48
和乙级一个题目差不多,这个更简单,但是如果还用以前的方法会溢出,有一个测试过不了。
溢出代码:
include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <iomanip>using namespace std;int main(){ freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int g1, s1, k1, g2, s2, k2; scanf("%d.%d.%d", &g1, &s1, &k1); scanf("%d.%d.%d", &g2, &s2, &k2); int t1 = g1*17*29 + s1*29 + k1; int t2 = g2*17*29 + s2*29 + k2; int t = t1 + t2; int g = t/(17*29), s = (t%(17*29))/29, k = t-g*(17*29)-s*29; printf("%d.%d.%d", g, s, k); return 0;}
通过代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <iomanip>using namespace std;int main(){ freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int g1, s1, k1, g2, s2, k2; scanf("%d.%d.%d", &g1, &s1, &k1); scanf("%d.%d.%d", &g2, &s2, &k2); int g = 0, s = 0, k = 0; k = (k1+k2)%29; s = ((k1+k2)/29 + s1 + s2)%17; g = ((k1+k2)/29 + s1 + s2)/17 + g1 + g2; printf("%d.%d.%d", g, s, k); return 0;}
0 0
- PAT-A1058 A+B in Hogwarts (20)(模拟)
- 【PAT】A1058. A+B in Hogwarts (20)
- PAT A1058. A+B in Hogwarts (20)
- PAT A1058 A+B in Hogwarts
- PAT A1058 A+B in Hogwarts
- 1058. A+B in Hogwarts (20)- PAT
- 【PAT】1058. A+B in Hogwarts (20)
- PAT 1058. A+B in Hogwarts (20)
- PAT 1058. A+B in Hogwarts (20)
- pat 1058. A+B in Hogwarts (20)
- PAT 1058. A+B in Hogwarts (20)
- PAT 1058. A+B in Hogwarts (20)
- PAT-A+B in Hogwarts (20)
- PAT 1018A+B in Hogwarts (20)
- PAT---1058. A+B in Hogwarts (20)
- PAT(甲级)A+B in Hogwarts (20)
- PAT A 1058. A+B in Hogwarts (20)
- PAT(A) - 1058. A+B in Hogwarts (20)
- AndroidStudio快捷键
- Euclid‘s algorithm
- 支撑Spring的基础技术:反射,动态代理,cglib等
- Spring连接两个以上数据库
- vm下centos网络配置(转)
- PAT-A1058 A+B in Hogwarts (20)(模拟)
- 决策树
- ODBC和JDBC区别
- 常见Oracle HINT的用法
- C++基础总结(2)---字符串
- Java多线程之Executor框架(2)
- Cocos2d-x的坐标系
- noip 2000年 乘积最大 - DP
- HDOJ-1503 Advanced Fruits