A + B + C + D

Time Limit: 40000/20000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 130    Accepted Submission(s): 44

Problem Description
Little Robert asked his mother for two cents. "What did you do with
the money I gave you yesterday?""I gave it to a poor old woman," he
answered."You're a good boy," said the mother proudly. "Here are
two cents more. But why are you so interested in the old
woman?""She is the one who sells the candy."A joke, here
entered
Below n four tuple (A, B, C, D), respectively, from the A, B, C, D
selected a, b ,c ,d To calculate the number of combinations of
a+b+c+d = 0;
 
Input
The first line of the input file contains the size of the lists n
(1<= n <= 4000)
Then every line containing four integer values (with absolute value
as large as 2^28 )
 
Output
For each input file, your program has to write the number whose sum
is zero
 
Sample Input
6 -45 22 42
-16 -41 -27 56
30 -36 53 -37
77 -36 30 -75
-46 26 -38
-10
62 -32 -54 -6 45
 
Sample Output
5
 
 
 
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

;

int n;
int s1[maxn*maxn];
int s2[maxn*maxn];
int a[maxn],b[maxn],c[maxn],d[maxn];

int main()
{
//   freopen("in.txt", "r", stdin);
    while(~scanf("%d", &n))
    {;i<n;i++)
        scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
    ;i<n;i++)
        ;j<n;j++)
            s1[i*n+j]=a[i]+b[j];
    ;i<n;i++)
        ;j<n;j++)
            s2[i*n+j] = c[i]+d[j];
    sort(s1,s1+n*n);
    sort(s2,s2+n*n);
    ;
    ;
    ;i<n*n;i++)
    {
         && s1[i]+s2[r]>)
            r--;
        )break;
        int tmp = r;
         && s1[i]+s2[tmp] == )
            ans++, tmp--;
    }
    printf("%d\n", ans);
    }
    ;
}

最新文章

  1. 【Java EE 学习 79 上】【mybatis 基本使用方法】
  2. MyBatis的初始化方式
  3. &lt;随便写写&gt;
  4. ExtJS笔记 Store
  5. 分子量 (Molar Mass,ACM/ICPC Seoul 2007,UVa 1586)
  6. 【翻译】CEDEC2014 CAPCOM 照相机正确的照片真实的制作工作流
  7. 内工大acm校赛--整理代码
  8. Appium 服务命令行参数
  9. 五十个小技巧提高PHP执行效率(一)
  10. ACM | HDU|6227_Rabbit
  11. SQL Server函数与存储过程 计算时间
  12. SqlServer中的系统数据库
  13. vue-cli脚手架(框架)
  14. D.Starry的神奇魔法(矩阵快速幂)
  15. TP-Link 路由器配置 config.bin 解密工具 python 代码 (转载)
  16. Link Cut Tree学习笔记
  17. POJ-3744 Scout YYF I (矩阵优化概率DP)
  18. (转) MVC身份验证及权限管理-2
  19. systemtap安装
  20. $_ENV和$GLOBALS预定义变量

热门文章

  1. html5权威指南:设置文本样式
  2. php 异步
  3. grunt学习随笔
  4. 设置div控件居中的方法
  5. html readonly和disabled的区别
  6. Linux vim编辑器
  7. PHP中使用CURL(三)
  8. jQuery 事件 - bind() 方法
  9. Python 学习笔记8
  10. img转data