1 条题解

  • 0
    @ 2026-9-30 13:00:25

    C++ :

    
    #include <cstdio>
    typedef long long ll;
    int main(){
        int n,k;
        if(scanf("%d %d",&n,&k)!=2) return 0;
        static ll c[64];
        ll ans=0;
        for(int i=0;i<n;i++){
            int v; if(scanf("%d",&v)!=1) return 0;
            int r=v%k;
            for(int t=0;t<=r;t++) ans+=c[t];
            c[r]++;
        }
        printf("%lld\n", ans);
        return 0;
    }
    
    
    • 1

    信息

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