#include<stdio.h>
#include<string.h>
int main(void)
{
int t;
scanf("%d",&t);
while(t–)
{
int activities;
char origin[16];
scanf("%d%s",&activities,origin);
can anyone suggest what is wrong in the following code(multhree):
int main() {
// your code goes here
int t;
cin>>t;
while(t–){
long long k;
int d0,d1;
cin>>k>>d0>>d1;
if(k==2){
if((d0+d1)%3==0){
cout<< “YES” << “\n”;
continue;
}
else{
cout<< “NO” << “\n”;
continue;
}
}
int sum=(d0+d1);
int d2=sum%10;
int previous_sum= d0+d1+d2;
long long cycles= (k-3)/4;
long long cycles_sum= ((2sum%10)+(4sum%10)+(8sum%10)+(6sum%10))*cycles;
int left_over_terms=(k-3)%4;
int total_sum= previous_sum+cycles_sum;
for(auto i=1; i<=left_over_terms; i++){
total_sum+=(1<<i)*sum%10;
}
if(total_sum%3==0)
cout<< “YES”<< “\n”;
else
cout<< “NO”<< “\n”;
}
return 0;
}
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t–){
int i=1,val,k,a,b,sum=0,res=0;
cin>>k>>a>>b;
res=(k-2)%4;
for(int j=1;j<=res;j++)
i*=2;
if(res==0&&k>2)
i=6;
val=i*(a+b);
//cout<<val;
if(val%3==0)
cout<<“YES\n”;
else
cout<<“NO\n”;}
}
Can someone please tell me what is wrong in this sol for ques MULTHREE
SMARTPHONE PROBLEM
CAN ANY ONE TELL ME WHY MY SIMPLE CODE IS NOT PASSING ALL TEST CASE:
long long int T;
cin>>T;
long long int arr[T];
for(int i=0;i<T;i++)
cin>>arr[i];
sort(arr,arr+T);
long long int n=T/2 +1;
long long int Index=T-n;
long long int price = arr[Index]*n;
cout<<price;
return 0;