But, this is a different couple - this is a programming couple - and they argue on weird things, like Fibonacci numbers, prime numbers, Sterling numbers, and what not!
Their recent fight might seem silly to a lot of people, but it is a matter of serious concern for both of them. They have bought a cake, and they weighed it in milligrams - the weight of the cake is always even and now they wish to divide the cake between them in some way, that both of them are satisfied.
Arjit challenges Deepa that if she can divide the weight of the cake as the sum of two prime numbers between them, she can have the entire cake - and if she fails to do so, he'll get the cake.
The argument is getting more, and more heated now - please help them sort out their stupid arguments or an easier way would be to help them figure out who is going to have the cake.
Example:
Input: n = 4 Output: Deepa
Approach
C++
#include <bits/stdc++.h>using namespace std;bool isprime(int n){if (n <= 1)return false;for (int i = 2; i <= sqrt(n); i++)if (n % i == 0)return false;return true;}int main(){int n = 4;int flag = 0;for (int i = 2; i < n; i++){if (isprime(i) && isprime(n - i)){flag = 1;break;}}if (flag == 0)cout << "Arjit\n";elsecout << "Deepa\n";return 0;}
No comments:
Post a Comment