fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. bool prime(int a){
  4. for(int i=2; i*i<=a; i++)
  5. if(a%i==0) return false;
  6. return true;
  7. }
  8. int main() {
  9. int x=2, k=0;
  10. while(x<=50){
  11. if(prime(x)){
  12. cout<<x<<endl;
  13. string s;
  14. cin>>s;
  15. if(s=="yes"){
  16. k++;
  17. }
  18. if(x*x<=100){
  19. cout<<x<<endl;
  20. cin>>s;
  21. if(s=="yes"){
  22. k++;
  23. }
  24. }
  25. if(k>1){
  26. cout<<"composite"<<endl;
  27. return 0;
  28. }
  29. }
  30. x++;
  31. }
  32. cout<<"prime"<<endl;
  33. }
  34.  
Success #stdin #stdout 0.01s 5308KB
stdin
yes
no
yes
stdout
2
2
3
3
composite