Codeforces Round 886 (Div. 4)

F. We Were Both Children

Input 

7
5
1 2 3 4 5
3
2 2 2
6
3 1 3 4 9 10
9
1 3 2 4 2 3 7 8 5
1
10
8
7 11 6 8 12 4 4 8

10
9 11 9 12 1 7 2 5 8 10

Output 

3
3
3
5
0
4
4
 

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;

int v[N], n, m, k, x, t, T;
map<int, int> mp;
void ClearFloat()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{
    ClearFloat();
    cin >> T;
    while (T--)
    {
        memset(v, 0, sizeof v);
        cin >> n;
        for (int i = 1; i <= n; i++)
        {
            cin >> x;
            mp[x]++;
        }
        for (auto [a, b] : mp)
        {
            for (int i = a; i <= n; i += a)
                v[i] += b;
        }
        int ans = 0;
        for (auto i : v)
        {
            if (i > ans)
                ans = i;
        }
        cout << ans << endl;
        mp.clear();
    }
    return 0;
}

G. The Morning Star

 Input

5
3
0 0
-1 -1
1 1
4
4 5
5 7
6 9
10 13
3
-1000000000 1000000000
0 0
1000000000 -1000000000
5
0 0
2 2
-1 5
-1 10
2 11
3
0 0
-1 2
1 -2
 

Output 

6
2
6
8
0
 

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define xx first
#define yy second
typedef pair<int, int> PII;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 10;

int v[N], n, m, k, x, t, T, y;

void ClearFloat()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{
    ClearFloat();
    cin >> T;
    while (T--)
    {
        cin >> n;
        map<int, int> up, side, dig, udig;
        for (int i = 1; i <= n; i++)
        {
            cin >> x >> y;
            up[x]++;
            side[y]++;
            dig[x + y]++;
            udig[x - y]++;
        }
        int ans = 0;
        for (auto i : up)
            ans += i.second * (i.second - 1);
        for (auto i : side)
            ans += i.second * (i.second - 1);
        for (auto i : dig)
            ans += i.second * (i.second - 1);
        for (auto i : udig)
            ans += i.second * (i.second - 1);
        cout << ans << endl;
    }
    return 0;
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值