• + 3 comments

    @hirababu089 there is no possible way for which it could make a pair such as (3,0) becouse in the second loop the smallest value possible is i+1 (the inital j position) anyways here the entire code may be you are doing some silly mistake like putting j=1 instead of j=i+1; in second loop

    #include <math.h>
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <assert.h>
    #include <limits.h>
    #include <stdbool.h>
    
    int main() {
        int n; 
        int k; 
        int count=0;
        scanf("%d %d", &n, &k);
        int *a = malloc(sizeof(int) * n);
        for(int a_i = 0; a_i < n; a_i++){
           scanf("%d",&a[a_i]);
        }
        for(int i=0;i<n;i++)
            {
            for(int j=i+1;j<n;j++)
                {
                    if((a[i]+a[j])%k==0)
                        {
                        count++;
                    }
            }
        }
        printf("%d",count);
        
        // write your code here
        return 0;
    }