有点像筛法(?
#include<iostream> #include<vector> using namespace std; int convert(int n); int main() { const int max=1000001; vector<int> alone(max,1); for(int i=1; i<=max; ++i) alone[convert(i)]=0; for(int i=1; i<=max; ++i) if(alone[i]) cout<<i<<endl; return 0; } int convert(int n) { int sum=n; while(n!=0) { sum+=n%10; n/=10; } return sum; }
不用谢
int a[maxn];
int count(int n){ int re=n; while(n){ re+=(n%10); n/=10; } return re; }
void solve(){ memset(a, 0, sizeof(a)); for(int i=1;i<=1000000;i++){ a[count(i)]=1; } }
int main(int argc, const char * argv[]) { solve(); for(int i=1;i<=1000000;i++) if(!a[i]) printf(“%d\n”,i); return 0; }
我就是喜欢送答案
int main() { intp,i,sum=0,k; p=(int)malloc(sizeof(int)*1000000); for(i=1;i<=1000000;i++) p[i-1]=i; for(i=1;i<=1000000;i++) { k=i; while(k) { sum+=k%10; k/=10; } p[i+sum-1]=0; sum=0; } for(i=0;i<=999999;i++) { if(p[i]) printf(“%d\n”,p[i]); } return 0; }
有点像筛法(?
不用谢
int a[maxn];
int count(int n){
int re=n;
while(n){
re+=(n%10);
n/=10;
}
return re;
}
void solve(){
memset(a, 0, sizeof(a));
for(int i=1;i<=1000000;i++){
a[count(i)]=1;
}
}
int main(int argc, const char * argv[]) {
solve();
for(int i=1;i<=1000000;i++)
if(!a[i])
printf(“%d\n”,i);
return 0;
}
我就是喜欢送答案
include
include
include
include
int main()
{
intp,i,sum=0,k;
p=(int)malloc(sizeof(int)*1000000);
for(i=1;i<=1000000;i++)
p[i-1]=i;
for(i=1;i<=1000000;i++)
{
k=i;
while(k)
{
sum+=k%10;
k/=10;
}
p[i+sum-1]=0;
sum=0;
}
for(i=0;i<=999999;i++)
{
if(p[i])
printf(“%d\n”,p[i]);
}
return 0;
}