
看到這則新聞後覺得有點無語,這道題也難的沒那麼誇張,寫程序的話也簡單,希望媒體報道的新聞像個新聞,別什麼事都當新聞報,倒是希望多報一些關於科技和經濟的一些有價值的新聞。廢話少說,直接上代碼了。
#include<iostream>
#include<stdlib.h>
#include<fstream>
#include<time.h>
using namespace std;
int main(){
fstream outfile;
outfile.open("outNum.txt",ios::out);
cout<<"beginnig the count"<<endl;
time_t begin_time=time(0);
tm tim_begin=*localtime(&begin_time);
int allofNum=0,num=0;
for(int a=1;a<10;a++){
for(int b=1;b<10;b++){
for(int c=1;c<10;c++){
for(int d=1;d<10;d++){
for(int e=1;e<10;e++){
for(int f=1;f<10;f++){
for(int g=1;g<10;g++){
for(int h=1;h<10;h++){
for(int i=1;i<10;i++){
int N[9]={a,b,c,d,e,f,g,h,i};
if(66==a+13*b/c+d+12*e-f-11+g*h/i-10&&(0==b%c)&&(0==g%h)){
outfile<<a<<","<<b<<","<<c<<","<<d<<","<<e<<","<<f<<","<<g<<","<<h<<","<<g<<","<<i<<endl;
cout<<a<<","<<b<<","<<c<<","<<d<<","<<e<<","<<f<<","<<g<<","<<h<<","<<g<<","<<i<<endl;
num++;
}
allofNum++;
}
}
}
}
}
}
}
}
}
cout<<"the end"<<endl;
cout<<"the all of Num is: "<<allofNum<<endl;;
cout<<"the num is: "<<num<<endl;;
outfile.close();
time_t end_time=time(0);
tm tim_end=*localtime(&end_time);
int usetime_sec=tim_end.tm_sec-tim_begin.tm_sec;
cout<<"using time "<<usetime_sec<<endl;
return 0;
}


從輸出結果可以看出有上面的題總共有230389個解,用最基本的佛如for循環計算的話需要9秒鐘時間,有錯誤的話希望大家指出來。