Video Editorials for December Long

Hey guys!
I will be posting video editorials for the December Long challenge here.

  1. Total Diamonds

  2. Chef and Hamming Distance of Arrays

Cheers!

4 Likes

thank u so much!

please do a tutorial on CHEFFIB , WESTAND and DSANTAP

#include<stdio.h>

int mod(int b){
if(b<0){
return (-1)*b;
}else{
return b;
}

}

int main(){
int t;
scanf("%d",&t);
int i,d[t];
long long int *a;
int *b;
a=(long long int *)malloc(sizeof(long long int)*1000000);
b=(int )malloc(42000001);
b[0]=0;
for(i=1;i<2000001;i++){
int r=i%10;
int k=i/10;
if(r%2==0){
b[i]=b[k]+r;}
else{
b[i]=b[k]-r;
}
}

a[0]=2;
a[1]=12;
for(i=2;i<1000000;i++){
a[i]=2a[i-1]-a[i-2]-mod(2b[i+1])+mod(b[2i])+mod(2b[2i+1])+mod(b[2i+2]);
}

for(i=0;i<t;i++){
scanf("%d",&d[i]);
}
for(i=0;i<t;i++){
printf("%lld\n",a[d[i]-1]);
}

return 0;
}