Bedao Mini Contest 25 - Trọng số lẻ

View as PDF

Submit solution

Points: 0.01 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Author:
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

Cho một mảng ~a~ gồm ~n~ số nguyên dương ~a_1, a_2, ..., a_n~. Gọi trọng số của mảng là tổng của các (~a_i + a_j~) ~(1 \le i \le j \le n~) thỏa mãn ~a_i + a_j~ lẻ. Bạn hãy tìm trọng số của mảng ~a~.

Vì trọng số có thể rất lớn, hãy in ra kết quả ~\mod 10^9+7~.

Input

Dòng đầu tiên gồm số nguyên dương ~n~ (~1 \le n \le 10^6~).

Dòng thứ hai gồm ~n~ số nguyên dương ~a_1, a_2, ..., a_n~ (~1 \le a_i \le 10^9~).

Output

Gồm một dòng duy nhất là trọng số của mảng ~a~ ~\mod 10^9+7~.

Scoring

Subtask Điểm Giới hạn
1 ~40\%~ ~N \le 10^3~
2 ~60\%~ Không có giới hạn gì thêm

Sample Input 1

5
3 7 2 1 9

Sample Output 1

28

Sample Input 2

5
6 8 2 2 10

Sample Output 2

0

Notes

Trong test ví dụ đầu tiên, các cặp số thỏa mãn là (~1, 3~), (~2, 3~), (~3, 4~), (~3, 5~). Vậy trọng số là ~(a_1 + a_3) + (a_2 + a_3) + (a_3 + a_4) + (a_3 + a_5)~ = ~3 + 2 + 7 + 2 + 2 + 1 + 2 + 9 = 28~.

Trong test ví dụ thứ hai, không có bất kì cặp nào có tổng là số lẻ nên trọng số của mảng ~[6, 8, 2, 2, 10]~ là ~0~.


Comments

Please read the guidelines before commenting.



  • -1
    petercon123  commented on Dec. 10, 2025, 12:54 p.m.

    .


  • -1
    okokokkokk  commented on June 20, 2025, 9:28 a.m.

    include <bits/stdc++.h>

    using namespace std; typedef long long ll;

    int main() { iosbase::syncwith_stdio(false); cin.tie(NULL);

    ll n, tong = 0, kq = 0;
    const ll mod = 1e9 + 7;
    cin >> n;
    
    vector<ll> a(n), chan, le;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0)
            chan.push_back(a[i]);
        else
            le.push_back(a[i]);
    }
    
    if (!chan.empty() && !le.empty()) {
        ll len = chan.size();
        for (ll i : chan)
            tong = (tong % mod + i % mod) % mod;
        for (ll x : le) {
            ll temp = (tong + (len * x) % mod) % mod;
            kq = (kq + temp) % mod;
        }
    }
    
    cout << kq;
    return 0;
    

    }


  • 0
    khang755332  commented on April 16, 2025, 7:34 a.m.

    .


  • 0
    truongcanhchan  commented on Feb. 17, 2025, 6:46 a.m. edited

    Cuối cùng sau n lần submit, tôi đã giải được bài này rồi GGGGGGGGG


  • 4
    phamhaidang123654  commented on Nov. 12, 2024, 6:41 a.m.

    n=int(input()) m=list(map(int,input().split())) dayle=[] daychan=[] for k in m: if k%2==0: daychan.append(k) else: dayle.append(k) tongchan=sum(x for x in daychan)len(dayle) tongle=sum(x for x in dayle)len(daychan) print(tongchan+tongle)


  • -16
    Helectric  commented on Oct. 31, 2024, 7:09 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -10
    haianh11112013  commented on Oct. 26, 2024, 7:17 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -6
    honglamtapcode  commented on Oct. 18, 2024, 3:42 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -23
    kietjumper  commented on Oct. 4, 2024, 2:36 p.m. edit 3

    This comment is hidden due to too much negative feedback. Show it anyway.