Uva - 712 - S-Trees
2015-06-18 19:38
323 查看
第一次不小心用printf输出WA了,还是要把输入输出统一起来,切记切记。题目不难,按路径算出叶子结点,最后统一输出就行了。
AC代码:
#include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cstring> #include <string> #include <sstream> #include <vector> #include <set> #include <map> #include <algorithm> #include <stack> #include <queue> #include <bitset> #include <cassert> #include <cmath> using namespace std; const int maxn = 1000; int n, m, sum; string str[10], mstr[maxn]; // mstr存储操作的步骤 char num[maxn]; // 结点的值 int main() { ios::sync_with_stdio(false); int kase = 0; while (cin >> n && n) { sum = pow(2, n); // 输入结点 for (int i = 0; i < n; i++) { cin >> str[i]; } cin >> num; cin >> m; int temp; for (int i = 0; i < m; i++) { cin >> mstr[i]; } cout << "S-Tree #" << ++kase << ":\n"; //printf("S-Tree #%d:\n", ++kase); for (int i = 0; i < m; i++) { temp = 0; for (int j = 0; j < n; j++) { temp += (mstr[i][j] - '0') * pow(2, n - j - 1); } cout << num[temp]; } cout << endl << endl; } return 0; }
相关文章推荐
- Uva - 712 - S-Trees
- 博弈论汇总
- 2015-6-18 按钮菜单图片(正常,按下);scheduleUpdate;移动背景
- 路由器WAN口和LAN口的区别
- LeetCode——Count and Say
- 创建loopback环回网卡
- Java并发编程-26-异步运行任务
- cvLoadImage无法载入图像,返回空指针
- leetcode----数字
- 修改窗口过程函数:按下回车后 焦点转移到下一个编辑框
- JAVA五子棋项目总结
- java中包的命名
- Windows 2008R2部署Win 7/2008R2+Office2010(+2013)+Win 8/2012(+win8.1/2012R2) KMS激活服务器
- How to forward from one JSP to another JSP
- POJ3186:Treats for the Cows
- POJ 2263 最短路Floyd_warshall算法
- [LeetCode]String to Integer (atoi)
- Ibatis
- subprocess使用方法
- 赫夫曼编码实现