We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
@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>intmain(){intn;intk;intcount=0;scanf("%d %d",&n,&k);int*a=malloc(sizeof(int)*n);for(inta_i=0;a_i<n;a_i++){scanf("%d",&a[a_i]);}for(inti=0;i<n;i++){for(intj=i+1;j<n;j++){if((a[i]+a[j])%k==0){count++;}}}printf("%d",count);// write your code herereturn0;}
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all 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