zoukankan      html  css  js  c++  java
  • 2020 CCPC Wannafly Winter Camp Day6 Div.1&2 N 合并!

    题目链接:https://ac.nowcoder.com/acm/contest/4137/N

    其实看到数据量 2000应该要想到时间复杂度基本就On2

    题解:不管怎么合并,答案都一样的, 所有数两两乘积的和

    代码

    #include<iostream>
    #include<string>
    #include <cstdlib>
    #include <algorithm>
    #include<cmath>
    #include<cstring>
    #include<cstdio>
    #include<vector>
    #include<queue>
    #include<map>
    #include<set>
    #include<bitset>
    #include <iomanip>
    
    // #pragma comment(linker, "/STACK:1024000000,1024000000")
    // #define pi acos(-1)
    // #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define INF 0x7f7f7f7f //2139062143
    #define INF1 0x3f3f3f3f //1061109567
    #define INF2 2147483647
    #define llINF 9223372036854775807
    #define pi 3.141592653589793//23846264338327950254
    #define pb push_back
    #define ll long long
    #define debug cout << "debug
    ";
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    #define CNM ios::sync_with_stdio(false);cin.tie(NULL);
    #define scai(x) scanf("%d", &x)
    #define sca2i(x, y) scanf("%d %d", &x, &y)
    #define scaf(x) scanf("%lf", &x)
    #define sca2f(x, y) scanf("%lf %lf", &x, &y)
    #define For(m,n) for (int i = m;  i < n; i++)
    
    inline int read(){
       int s=0,w=1;
       char ch=getchar();
       while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
       while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
       return s*w;
    }
    #define local
    #ifdef local
    #endif
    
    #define MAX 10233
    #define LCH(i) ((i) << 1)
    #define RCH(i) ((i) << 1 | 1)
    const int N = 2000 + 5;
    int a[N];
    
    int main()
    {
        CNM
        // freopen("in.txt","r",stdin);
        ll ans = 0;
        int n;
        cin >> n;
        for (int i = 0; i < n; i++) cin >> a[i];
        for (int i = 0; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                ans += a[i]*a[j];
            }
        }
        cout << ans << endl;
        return 0;
    }
  • 相关阅读:
    SugarCRM SupPanel删除键不好用
    SugarCRM 一个页面控制两个模块(editview.php)
    使用组策略去除每次打开IE7的”自定义您的设置”
    SugarCRM SupPanel表头显示不正确
    SugarCRM 去掉 模块标题左边的 问号 和 帮助
    SugarCRM 在Html中增加超连接按钮
    C#中设置状态栏(statusStrip)的布局
    poj2418 Hardwood Species *
    算法导论15.54
    算法导论9.37
  • 原文地址:https://www.cnblogs.com/hulian425/p/12249561.html
Copyright © 2011-2022 走看看