acm 2010求素数
**#include<iostream>
#include<math.h>
using namespace std;
int main(){
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
int count=0;
if(m>n){
int temp;
temp=m;
m=n;
n=temp;
}
for(int i=m;i<=n;i++){
int ge=i%10;
int shi=i/10%10;
int bai=i/100;
if(i==ge*ge*ge+shi*shi*shi+bai*bai*bai){
count++;
if(count==1) cout<<i;
else
cout<<" "<<i;
}
}
if(count!=0){
cout<<endl;
}
if(count==0){
cout<<"no"<<endl;
}
}
return 0;
}**
分析:这一题的难度我认为主要是在输出的格式方面,注意在输出素数的时候最后一行是不允许有空格的,否则oj无法通过。所以在只需要在输出第一个和非第一个的数加以区别就OK