The terrorist hijacked the famous Taj hotel in Mumbai and it has many VIPs, children, and family members. The hotel manager decides to inform the police but he wants to send the message without the knowledge of terrorists. So, he sends the message in the form of an encrypted number. Unfortunately, the message is received by the terrorist. The terrorist has to enter the number if they want to read the message. If the resultant of adding the encrypted number and number entered by a terrorist is a perfect number, then they can read the message. Otherwise, they can't read the message. A perfect number is a number which is equal to the sum of its proper positive divisors, excluding the number itself. Input Format: The first input contains an integer which denotes the encrypted number The second input contains an integer which denotes the number entered by a terrorist Output Format: If the resultant of adding the encrypted number and number entered by a terrorist is a perfect number, then print "They can read the message". Otherwise, print "They can't read the message".
Answers
Answer:
#include<iostream>
using namespace std;
int main()
{
int Enum,Tnum,sum=0;
cin>>Enum>>Tnum;
int n=Enum+Tnum;
for(int i=1;i<=n/2;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)
cout<<"They can read the message";
else
cout<<"They can't read the message";
return 0;
}
Explanation:
Answer:
#include<iostream>
using namespace std;
int main()
{
int Enum,Tnum,sum=0;
cin>>Enum>>Tnum;
int n=Enum+Tnum;
for(int i=1;i<=n/2;i++)
{
if(n%i==0)
sum=sum+i;
}
if(sum==n)
cout<<"They can read the message";
else
cout<<"They can't read the message";
return 0;
}
Explanation:
This programming codes has been created as per to the current input Format: The first input contained an integer which denotes the encrypted number The second input contains an integer which denotes the number entered by a terrorist.. & in the current output format: If the resultant of adding the encrypted number and number entered by a terrorist is a perfect number, then print "They can read the message". Otherwise, print "They can't read the message".