Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- bool mark[100005]={false};
- void sieve()
- {
- int i,j,k=0;
- mark[0]=true;
- for(i=2;i*i<=100000;i++)
- {
- if(mark[i]==false)
- {
- for(j=i*i;j<=100000;j+=i)
- {
- mark[j]=true;
- }
- }
- }
- }
- int main()
- {
- sieve();
- int i;
- string s;
- while(cin>>s)
- {
- int sum=0;
- for(i=0;i<s.size();i++)
- {
- if(s[i]>='a' && s[i]<='z')
- sum+=s[i]- 'a' +1;
- else
- sum+=s[i]- 'A' +27;
- }
- if(mark[sum]==false)
- cout<<"It is a prime word."<<endl;
- else
- cout<<"It is not a prime word."<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement