3 条题解

  • 1
    @ 2026-9-24 23:32:24

    下面是代码,祝每位旅行者永远不歪,十连双金

    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    static long long cnt[1024];
    
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    
        int n;
        if (!(cin >> n)) return 0;
    
        for (int i = 0; i < n; ++i) {
            long long x;
            cin >> x;
            int mask = 0;
            while (x) {
                mask |= (1 << (x % 10));
                x /= 10;
            }
            cnt[mask]++;
        }
    
        long long ans = 0;
        for (int i = 1; i < 1024; ++i) {
            if (!cnt[i]) continue;
            ans += cnt[i] * (cnt[i] - 1) / 2;
            for (int j = i + 1; j < 1024; ++j) {
                if (!cnt[j]) continue;
                if (i & j) {
                    ans += cnt[i] * cnt[j];
                }
            }
        }
    
        cout << ans << "\n";
        return 0;
    }
    

    最后附上神秘小图片:

    • 0
      @ 2024-12-13 18:43:17

      我不会做抽卡会歪吗?(doge)

      • 1

      信息

      ID
      3188
      时间
      1000ms
      内存
      256MiB
      难度
      9
      标签
      (无)
      递交数
      44
      已通过
      4
      上传者