Challenging Lover

Greetings to all of you. You must have heard about our star programmer Rafat bhai. One day he went o…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

whats the problem here?


#include<set>
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<climits>
#include<cstring>
#include<cmath>
#include<unordered_map>
#include<sstream>
#include<cmath>
#include<iomanip>
#include<numeric>
using namespace std;

bool is(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(!(n%i)) return false;
	}
	return true;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		long long int res=0;
		for(int i=1;i<=a;i++){
			if(!(a%i)) res+=i;
		}
		is(res)? cout<<"Yes"<<endl : cout<<"No"<<endl;
	}
}
#include <stdio.h>

int main() 
{
	long long int t,n,sum,is,rem,i;
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		sum=0;
		for(i=1;i<=n;i++){
			if(n%i==0){
				sum=sum+i;
			}
		}
		is=1;
		for(i=2;i<sum;i++){
			if(sum%i==0){
				is=0;
			}
		}
		if(is==1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	
	return 0;
}

Why it is showing wrong answer in Test Case 2 ?

#include <stdio.h>

int main()
{
long long int t,n=1,sum,is,rem,i;
scanf(“%lld”,&t);
while(t–){
scanf(“%lld”,&n);
sum=0;
for(i=1;i<=n;i++){
if(n%i==0){
sum=sum+i;
}
}
is=1;
for(i=2;i<sum;i++){
if(sum%i==0){
is=0;
}
}
//printf(“%lld-”,n);
if(is==1 && n!=1 && n!=0)
printf(“Yes\n”);
else
printf(“No\n”);
//n++;
}

return 0;

}