【A + B + C + D】 问题

时间:2022-10-31 21:23:39

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. mysql创建用户及授权相关命令

    移步: https://zhidao.baidu.com/question/1576368583039067980.html

  2. spring 事务:注解方式

    (1) .<context:component-scan base-package="*.*" /> 该配置隐式注册了多个对注解进行解析的处理器,如: Autowire ...

  3. How to retrieve instance parameters from an uninstantiated &lpar;uninserted&rpar; family

    The trick to be able to read the default values for instance parameters is to get to the FamilyManag ...

  4. mongodb中的副本集搭建实践

    准备运行1个主节点,2个从节点,从节点中其中是一个是仲裁节点(Arb). --oplogSize --oplogSize --oplogSize 其中application是副本集的名称,节点必须相同 ...

  5. vmware装redhat该光盘无法被挂载

    为了考网工,没办法只能学学linux了,前天在vmware7装redhat 提示该光盘无法被挂载,还以为是光盘错误,换了N个盘,又装了很多次,最后观察到,换了盘之后点确定,里面就提示该光盘无法被挂载, ...

  6. windows下使用openssl的一种方法

    下载openssl之后,全部解压到一个路径下,如:c:\program files\openssl sdk 举个例子,如使用SHA1,开发时引用头文件: #include <sha.h> ...

  7. 数据同步DataX

    数据同步那些事儿(优化过程分享)   简介 很久之前就想写这篇文章了,主要是介绍一下我做数据同步的过程中遇到的一些有意思的内容,和提升效率的过程. 当前在数据处理的过程中,数据同步如同血液一般充满全过 ...

  8. js原生获取元素的css属性

    习惯了用jQuery的css()的方法获取元素的css属性,突然不用jquery了,当要获得元素的css时候,我瞬间停顿了一下,咦?咋获取元素的css值?比如获取元素的width.是这样么?docum ...

  9. vue css背景图片打包后路径问题

    limit,代表如果小于大约4k则会自动帮你压缩成base64编码的图片,否则拷贝文件到生产目录 name,后面是打包后的路径: loader,后面 limit 字段代表图片打包限制,这个限制并不是说 ...

  10. java中字符串&quot&semi;1999-10-01T00&colon;00&colon;00&plus;08&colon; 00&quot&semi; 转化为Date格式

    String oldStr = "1999-10-01T00:00:00+08: 00": SimpleDateFORMAT sdf = new SimpleDateFORMAT ...