# Contest 1 - Hints to Problems [OFFICIAL]

Hi,
Can anyone please explain me how to solve Multiple of 3 (Problem Code: MULTHREE).
I am getting the right answer only for first testcase given in the problem. For 2nd testcase I am getting wrong and 3rd testcase it takes too long for execution.

where exactly??

I am getting garbage value for Laddu question. This is my code. Pls help!

#include <stdio.h>
#include <string.h>

int main(void) {
int T, acts, temp;
char nation, str[20];
char a[] = “CONTEST_WON”;
char b[] = “TOP_CONTRIBUTOR”;
char c[] = “BUG_FOUND”;

``````scanf("%d", &T);

while(T--) {
scanf("%d %c", &acts, &nation);

for(int i=0; i<acts; i++) {
scanf("%s", str);

if(!strcmp(str, a)) {
scanf("%d", &temp);
}

else if(!strcmp(str, b))

else if(!strcmp(str, c)) {
scanf("%d", &temp);
}

else laddu += 50;
}

if(nation == 'I') printf("%d\n", laddu/200);
}
return 0;
``````

}

MULTHREE Problem
Here’s my code for the problem with complexity O(1).
It’s still giving TLE by 0.01s.
I don’t think it can be optimized further .
Please have a look.

Okay,Brother you got right but check your solution for this case {2,3,4,5,97}, here the middle element is 4 but answer is 97, in this case you have to check for each element , You just have to need two array sort first one and solve one and put it in second array and sort them. You will Get the answer right. Hope you like it.

for lapindromes you can sort first half and second half then compare…

#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
for(int i = 0; i < t; i++){
unsigned long long int k;
int d0, d1;
cin>>k>>d0>>d1;
int base = d0 + d1;
unsigned long long sum = 2 * (d0 + d1);
if(sum == 10){
cout<<“NO”<<endl;
continue;
}
else{
int it = (k - 3)/4;
sum += (20 * it);
for(int m = 1; m <= ((k - 3) % 4); m++){
int x = (pow(2, m)*base);
sum += (x % 10);
}
}
if(sum % 3 == 0){
cout<<“YES”<<endl;
}
else
cout<<“NO”<<endl;
}
return 0;
}

This is my code for multiple of 3… Can someone tell me why it is showing WA