Another a+b FZU
来源:互联网 发布:面向对象编程的优势 编辑:程序博客网 时间:2024/05/18 02:26
a[i] + a[j] = M and 1<=i < j <=N.
初始的顺序其实没有关系
排序以后,对于要查找与a[i]匹配的值,范围[0,i-1].
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <vector> #include <map> #include <cmath> #include <set> #include <queue> using namespace std; const int INF=1e9+10; const double EPS = 1e-10; typedef long long ll; const int mod=1e9+7;int a[100005];int main(){int n,m;while(scanf("%d %d",&n,&m)!=EOF){for(int i=0;i<n;i++)scanf("%d",&a[i]);ll cnt=0;sort(a,a+n);for(int i=0;i<n;i++){int l=lower_bound(a,a+i,m-a[i])-a;int r=upper_bound(a,a+i,m-a[i])-a;cnt+=1LL*(r-l);}printf("%I64d\n",cnt);} return 0;}
阅读全文
0 0
- Another a+b FZU
- Fzu 2058 Another a+b【离散化+思维】
- 1001 - Another A+B
- Another A+B
- FZU A-B problem
- HUST 1001 Another A+B
- FZU 2147 A-B Game
- FZU 2147 A-B Game
- FZU 1752 a^b%c
- FZU-2147 A-B Game
- FZU 2147A-B Game
- FZU 2147 A-B Game
- 西安电子Problem 1002 - another a+b
- 2013资格赛——Another A+B
- Gym 100735 - I. Yet another A + B
- FZU 1752 A^B mod C
- FZU 1650 1752 a^b mod c
- FZU 1759 Super A^B mod C
- Sorting Information with Comparable -Swift中实例的排序问题
- Docker源码分析(四)之Docker Server
- Log4cpp 库安装及使用
- JS的面向对象-工厂方式-原型-继承
- 数据结构:链表队列
- Another a+b FZU
- 基于S3C2440的busybox的移植---解决FL2440的shell指令不能自动补全
- div模拟textarea高度随文本变化
- 一个手风琴效果的jquery动画
- 值得学习的C/C++语言开源项目
- Ubuntu 下 NFS环境的搭建
- scala 随笔(4) implicit 隐式转换 和冲突解决
- AJax请求数据用Jquary向select追加<option>
- R语言遗传算法