[Coursera]算法基础_Week4_动态规划(1)_Q1
2015-12-13 15:56
351 查看
#include <iostream> #include <set> using namespace std; int main() { int n; cin >> n; while (n--) { int s, res = 0; cin >> s; multiset<int> a; multiset<int> b; int na; cin >> na; while (na--) { int i; cin >> i; a.insert(i); } int nb; cin >> nb; while (nb--) { int i; cin >> i; b.insert(i); } for (multiset<int>::iterator i = a.begin(); i != a.end(); i++) { multiset<int>::iterator j = b.find(s - *i); if (j != b.end()) { for (; j!=b.end(); j++) { if (*j == s - *i) res++; else break; } } } cout << res << endl; } return 0; }
相关文章推荐
- Python3切换华为hi link设备数据开关
- DVWA系列之11 Brute Force中的密码绕过
- DVWA系列之11 Brute Force中的密码绕过
- Poj3984- dfs -迷宫问题
- MTK校准默认参数修改(2010-3-29 16:16)
- 数据结构问题集锦 - Max Points on a Line问题
- 流程
- Redhat7 配置ipv6
- 分享Python字符串关键点
- [Coursera]算法基础_Week3_递归_Q2
- web工程复制后改名字后遇到问题,怎么解决
- python 多线程学习
- 倍数提高工作效率的 Android Studio 奇技
- iOS Block传值
- 【openjudge】仙岛求药
- 使用SDWebImage时的内存管理问题
- jQuery动画入门--顺序执行
- 关于字符串的判断为空
- [leetcode] 264. Ugly Number II 解题报告
- 推荐Sql Server的博客