TOJ 4110 A+B
来源:互联网 发布:淘宝太坑了女主角 编辑:程序博客网 时间:2024/06/06 01:31
It's a simple hash problem.
You hash the number.and you get the answer.
The portal:http://acm.tju.edu.cn/toj/showp4110.html
#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>long long f[1005];void Deal_with(){ int T,n,q; scanf("%d",&T); while(T--){ memset(f,0,sizeof(f)); scanf("%d",&n); for(int i=0;i<n;i++){ int tempa; scanf("%d",&tempa); f[tempa] ++; } scanf("%d",&q); long long ans; for(int i=0;i<q;i++){ int tempa; ans = 0; scanf("%d",&tempa); for(int i=0;i<=1000;i++){ if(f[i] == 0)continue; if(tempa - i < 0 || tempa - i > 1000) continue; if(i == tempa - i)ans += f[i] * (f[i] - 1); else ans += f[i] * f[tempa - i]; } printf("%lld\n",ans); } }}int main(void){ //freopen("a.in","r",stdin); Deal_with(); return 0;}
0 0
- TOJ 4110 A+B
- TOJ A+B Problem
- TOJ 10008 a^b mod c
- TOJ-2234. A+B In the Future
- TOJ 2199 A+B Problem的无奈 2006-07-21
- TOJ 1154. A Mathematical Curiosity
- TOJ 4107 A simple problem
- toj 4611 Repairing a Road
- toj 4612 A Shooting Game
- TOJ 2793.A Simple Problem
- a>b?a:b
- ACM TOJ 1283 A DP Problem
- TOJ 3010 Reverse a Road / dijkstra
- TOJ 1804 The Machinegunners in a Playoff
- 【TOJ 3701.】A Pungent Problem【树链刨分】
- TOJ : 1794. The Bottom of a Graph
- toj 4608 Ball in a Rectangle
- a+b
- Windows 文件编码
- hadoop学习环境
- 请求返回JSON字符串时,IE出现下载对话框的解决方案
- 针对ListView 使用ListViewItem模板导致的ItemSource 变成对象 的原因
- 网络安全攻防学习资料推荐
- TOJ 4110 A+B
- XAML中特殊字符
- javascript基础八(知识点类闭包)
- VC++下使用ADO操作数据库的智能指针_ConnectionPtr、_RecordsetPtr、_CommandPtr的方法
- Spring bean数量统计
- 《程序员面试宝典》 —— 多态的作用
- nginx实现简单模块开发
- 如何在quartz的job中实现spring的依赖注入
- 51nod 1400 序列分解(DFS + 剪枝)