Advertisement
Farjana_akter

Untitled

Mar 13th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool mark[100005]={false};
  4.  
  5. void sieve()
  6. {
  7. int i,j,k=0;
  8. mark[0]=true;
  9. for(i=2;i*i<=100000;i++)
  10. {
  11. if(mark[i]==false)
  12. {
  13. for(j=i*i;j<=100000;j+=i)
  14. {
  15. mark[j]=true;
  16. }
  17. }
  18. }
  19. }
  20. int main()
  21. {
  22. sieve();
  23. int i;
  24. string s;
  25. while(cin>>s)
  26. {
  27. int sum=0;
  28. for(i=0;i<s.size();i++)
  29. {
  30. if(s[i]>='a' && s[i]<='z')
  31. sum+=s[i]- 'a' +1;
  32. else
  33. sum+=s[i]- 'A' +27;
  34. }
  35. if(mark[sum]==false)
  36. cout<<"It is a prime word."<<endl;
  37. else
  38. cout<<"It is not a prime word."<<endl;
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement