zoukankan      html  css  js  c++  java
  • CC三元组题解

    简单题直接上代码因为真的很简单

    #include <algorithm>
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <cstdio>
    #include <vector>
    #define itn int
    #define reaD read
    #define N 100005
    #define mod 1000000007
    #define int long long
    using namespace std;
    int T, p, q, r, a[N << 1], b[N << 1], c[N << 1], pos1, pos2, cnt1, cnt2, sum1, sum2; 
    inline int read(){
    	int x = 0, w = 1; char c = getchar();
    	while(c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); }
    	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    	return x * w;
    }
    signed main(){
    	T = read();
    	while(T--){
    		p = read(); q = read(); r = read();
    		for(int i = 1; i <= p; i++)	a[i] = read();
    		for(int i = 1; i <= q; i++)	b[i] = read();
    		for(int i = 1; i <= r; i++)	c[i] = read();
    		sort(a + 1, a + p + 1);
    		sort(b + 1, b + q + 1);
    		sort(c + 1, c + r + 1);
    		long long ans = 0; 
    		pos1 = pos2 = 1; cnt1 = cnt2 = 0; sum1 = sum2 = 0; 
    		for(int i = 1; i <= q; i++)
    		{
    			while(pos1 <= p && a[pos1] <= b[i])
    			{
    				sum1 = 1ll * (sum1 + a[pos1]) % mod;
    				cnt1++; pos1++; 
    			}
    			while(pos2 <= r && c[pos2] <= b[i])
    			{
    				sum2 = 1ll * (sum2 + c[pos2]) % mod;
    				cnt2++; pos2++; 
    			}
    			ans = (1ll * ans + 1ll * cnt1 * cnt2 % mod * b[i] % mod * b[i] % mod) % mod;
    			ans = (1ll * ans + 1ll * b[i] * (1ll * sum1 * cnt2 % mod + sum2 * cnt1 % mod) % mod) % mod;
    			ans = (1ll * ans + 1ll * sum1 * sum2 % mod) % mod; 
    		}
    		printf("%lld
    ", ans); 
    	}
    	return 0;
    } 
    
  • 相关阅读:
    [HNOI2019]JOJO
    [TJOI2019]唱、跳、rap和篮球
    [ZJOI2019]开关
    jzoj5746
    [JSOI2019]神经网络(指数生成函数)
    [TJOI2019]甲苯先生的线段树
    [JSOI2019]节日庆典
    XSY1519
    XSY1528
    springboot actuator监控笔记
  • 原文地址:https://www.cnblogs.com/cancers/p/11276718.html
Copyright © 2011-2022 走看看