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. 关于通过addClass与removeClass用jquery控制有良好兼容的CSS3样式

    hi:)好久不见~最近被jquery的animate对某些CSS3特性不兼容搞的头晕眼花,果断百度,阅读了一些高手的博客后突然发现平常很少用到的addClass和removeClass属性居然还可以这 ...

  2. 大D实例化model-->调用自定义类方法,大M调用原声model方法

    class ContactsModel extends Model{ public function addxxx(){ } } $conmodel = D('contacts','Model'); ...

  3. tomcat 7 启动超时设置。。。实在太隐蔽了

    打开Tomcat,选择 Window->Show View->Servers,在主窗口下的窗口中的Servers标签栏鼠标左键双击tomcat服务器名,例如 Tomcat v7.0 Ser ...

  4. SIM卡信息的管理

    MTK平台上,所有插入到手机中的SIM卡的信息都会存储在数据库com.android.providers.telephony中. 原始的数据库 图表 1 SimInfo数据表的结构 从上图示中,我们可 ...

  5. ADO.NET 完整修改、删除、防字符串攻击

    首先,我先把昨天所做的人事管理系统进行了优化,将其完善成为了一个更符合实际的系统.将修改及删除数据的数据库操作前面添加了一个查询语句,这样,在实际操作时,如果数据库中没有该条数据,则程序不会执行接下来 ...

  6. opencv轮廓处理函数详细

    ApproxChains 用多边形曲线逼近 Freeman 链 CvSeq* cvApproxChains( CvSeq* src_seq, CvMemStorage* storage, int me ...

  7. 多工段查询存放到DataTable到List<DataTable>集合在C#里面做汇总

    private void btnQuery_Click(object sender, EventArgs e) { if (cboxFactory.Text=="") { Mess ...

  8. 典型的DIV+CSS布局——左中右版式

    [效果] [HTML] <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Def ...

  9. js导入的注意.txt

    如有两个外部js文件: jquery-1.8.2.min.js Jqery的系统文件 LYFArray.js 和个人的 ===============我要将两个js文件导入一个页面的方法:====== ...

  10. wmts调用路径手工合成

    wmts调用路径手工合成 一般OGC WMTS地图只提供了xml描述,地图应用常常要合成WMTS完整的调用URL.我们需要获知以下参数: BaseURL:例如 "http://10.36.5 ...