#4546: 如何用根號縮時


jite4513 (以結)


#include<iostream>
#include <math.h>
using namespace std;
int main()
{     int a=0;
      while(cin>>a){
                                    for(int i=1; i<sqrt(a); i++){
                                    if(a%i==0 && a!=2 && i!=1){
                                              cout << "非質數" << endl;
                                              break;
                                    }
                                    else{
                                         if(i==a-1){
                                         cout <<"質數" << endl;
                                         }
                                    }
                            }
      }
      system("pause");
      return 0;
}

不知道怎麼縮時

幫忙一下

謝謝

#4547: Re:如何用根號縮時


asas (向諸神與地雷醬獻上祈禱)


你就算縮短時間 還是會WA~~