Skip to content

Instantly share code, notes, and snippets.

@jinnatul
Created January 15, 2019 06:43
Show Gist options
  • Save jinnatul/325793c74c609e9230e0a3ea3a272c56 to your computer and use it in GitHub Desktop.
Save jinnatul/325793c74c609e9230e0a3ea3a272c56 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
/// Typedef
typedef long long ll;
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
#define mx 10000007
#define mod 100000007
#define PI acos(-1.0)
int dr[] = {-2,-2,-1,-1,1,1,2,2};
int dc[] = {-1,1,-2,2,-2,2,-1,1};
ll primearray[2005] = {};
void sieve() {
for(ll i = 2; i < 2000; i++) {
if(primearray[i] == 0) {
for(ll j = 2; i*j < 2000; j++)
primearray[i*j] = 1;
}
}
}
int main()
{
ll num, m, tc = 1;
sieve();
char arr[30];
while (scanf("%s", arr) == 1){
ll num = 0, ln = strlen(arr);
for(ll i = 0; i < ln; i++){
if(arr[i] >= 'a' && arr[i] <= 'z')
num += arr[i] - 'a' + 1;
else
num += arr[i] - 'A' + 27;
}
if(primearray[num] == 0) cout << "It is a prime word." << endl;
else cout << "It is not a prime word." << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment