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. aws部署从无到有(二)windows管理aws

    1 AMI正常启动后会进入下面页面 2 远程链接点击如何连接至您的 Linux 实例进入下载页 Windows下使用 PuTTY连接到 Linux 实例 http://www.chiark.green ...

  2. @Transactional注解详解

    默认遇到throw new RuntimeException("...");会回滚   需要捕获的throw new Exception("...");不会回滚 ...

  3. jquey(判断文本框输入的网址链接是否符合规则)

    今天遇到一个问题,我要在文本框中输入一个网址链接,使其跳转.但是如何验证,我首先想到了正则表达式.对的,就是你想的那样,我对正则一知半解,但在我哥哥帮助下,最终是 实现 了效果.在此,来一发,分享一下 ...

  4. 移动端Bug管理工具——Bugtags

    Bugtags介绍 产品说明 Bugtags是为改善移动产品质量而专门打造的测试平台产品. 产品功能 SDK集成简单 一行代码极速集成,完全不影响原有程序结构. 所见即所得提交问题 一键截屏,使用标签 ...

  5. jbpm4.3表结构和表字段说明

    整体说明: JBPM4_DEPLOYMENT   流程定义表JBPM4_DEPLOYPROP 流程定义属性表 JBPM4_EXECUTION  流程实例表JBPM4_HIST_ACTINST 流程活动 ...

  6. 手机下的ev.pageX无效

      把  ev.pageX  换成  e.originalEvent.targetTouches[0].pageX;   例子: var start_x, start_y, end_x, end_y, ...

  7. redhat 时区修改

    修改系统时区,发现只需要一个命令就可以解决 修改之前: cp /usr/share/zoneinfo/Asia/Chongqing  /etc/localtime 修改之后:

  8. Openjudge-计算概论(A)-字符串排序

    描述 参考整数排序方法,设计一种为字符串排序的算法,将字符串从小到大输出 输入 第一行为测试数据组数t, 后面跟着t组数据.每组数据第一行是n,表示这组数据有n行字符串,接下来是要排序的n行字符串.每 ...

  9. UITextField的属性设置

    1.背景颜色 field.backgoundColor = [UIColor redColor]; 2.设置field文字 field.text = @"输入文字"; 3.设置fi ...

  10. “psql: could not connect to server: Connection refused” Error when connecting to remote database

    问题: I am trying to connect to a postgres database installed in a remote server using the following c ...