#include <iostream> #include <time.h> #include <math.h> using namespace std; //bool IsRational(int a,int b) //{ // //} int main() { double start = clock(),end(0); int count = 0; int totcount = 0; for(int a=100; a>1; --a) { for(int b=100; b>1; --b) { totcount++; if( (((a*a*a*a*a*a) <= 100) && (b%6==0 && b!=6)) || (((a*a*a*a*a) <= 100) && (b%5==0 && b!=5)) || (((a*a*a*a) <= 100) && (b%4==0 && b!=4)) || (((a*a*a) <= 100) && (b%3==0 && b!=3)) || (((a*a) <= 100) && (b%2==0 && b!=2)) ) { cout<< a<<" "<<b<<endl; count++; continue; } } } cout << totcount<<" - "<<count<< " = " <<totcount-count << endl; end = clock(); double result = (end - start)/1000; cout.setf(ios::fixed); cout <<endl<< "3.00GHz's run time = " << result << "s."<<endl; return 0; } #include <iostream> #include <time.h> #include <math.h> #include <set> #include <list> using namespace std; int main() { double start = clock(),end(0); int count = 0; int totcount = 0; set<long long> comb; set<long long> combcomb; list<long long> test; for(int a=10; a>1; --a) { for(int b=10; b>1; --b) { totcount++; test.push_front(pow((double)a,b)); comb.insert(pow((double)a,b)); if( ((a*a*a*a*a*a <= 10) && (a*a*a*a*a*a > 0) && (b%6==0 && b!=6) || (a%2==0 && b%3 ==0 && (a*b)%12==0)) || ((a*a*a*a*a <= 10) && (a*a*a*a*a > 0) && (b%5==0 && b!=5) || (a%2==0 && b%3 ==0 && (a*b)%12==0)) || ((a*a*a*4 <= 10) && (a*a*a*a > 0) && (b%4==0 && b!=4) || (a%2==0 && b%3 ==0 && (a*b)%12==0)) || ((a*a*a <= 10) && (a*a*a > 0) && (b%3==0 && b!=3) || (a%2==0 && b%3 ==0 && (a*b)%12==0)) || ((a*a <= 10) && (a*a > 0) && (b%2==0 && b!=2) || (a%2==0 && b%3 ==0 && (a*b)%12==0)) ) { //if(a>8) cout<< a<<" "<<b<<endl; combcomb.insert(pow((double)a,b)); count++; continue; } } } //test.sort(); for(set<long long>::iterator iter = comb.begin(); iter!=comb.end();iter++) { cout << *iter << " "; } cout<<endl<<"---------------------------------"<< endl; for(list<long long>::iterator iter = test.begin();iter!=test.end();iter++) { cout << *iter << " "; } cout<<endl<<"---------------------------------"<< endl; for(set<long long>::iterator iteriter = combcomb.begin(); iteriter!=combcomb.end();iteriter++) { cout << *iteriter << " "; } cout << endl <<"comb.size()"<< comb.size() << endl; cout << "combcomb.size()"<< combcomb.size() << endl; cout << "test.size()"<< test.size() << endl; cout << totcount<<" - "<<count<< " = " <<totcount-count << endl; end = clock(); double result = (end - start)/1000; cout.setf(ios::fixed); cout <<endl<< "3.00GHz's run time = " << result << "s."<<endl; return 0; }