Skip to content

Instantly share code, notes, and snippets.

@godtaehee
Created January 17, 2019 18:48
Show Gist options
  • Save godtaehee/ac47f0ff187016e255cea2727badb366 to your computer and use it in GitHub Desktop.
Save godtaehee/ac47f0ff187016e255cea2727badb366 to your computer and use it in GitHub Desktop.
C
#include <stdio.h>
void d(){
int x,y,w;
int arr[10001] = {0};
for(int n = 1; n < 10001; n++){
if(n < 10 && n > 0)
arr[2 * n]++;
else if(n >= 10 && n < 100){
arr[n + n / 10 + n % 10]++;
}
else if(n >= 100 && n < 1000){
x = n / 100;
y = (n - x * 100) / 10;
arr[n + x + y + n % 10]++;
}
else if(n >= 1000 && n < 10000){
x = n / 1000;
y = (n - x * 1000) / 100;
w = (n - x * 1000 - y * 100) / 10;
if((n + x + y + w + n % 10) <= 10000)
arr[n + x + y + w + n % 10]++;
}
}
for(int i = 1; i < 10001; i++){
if(arr[i] == 0)
printf("%d\n", i);
}
}
int main(){d();}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment