#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <climits>
#include <set>
#define MI INT_MAX
#define ULONG unsigned long long
#define LLONG long long
#define swap(a,b) {int t=a ; a=b ; b=t; }
#define sz(a) sizeof(a)
#define FOR(i, a, b) for (i=a ; i<b ; i++)
#define QSORT(a,n,s,f) qsort(a,n,sizeof(s),f)
using namespace std;
char s[10];
int digSum(int n)
{
int i, sum=0;
sprintf(s,"%d",n);
for (i=0 ; s[i] ; i++)
{
sum+=(s[i]-'0');
}
return sum;
}
bool ver[1000001]={false};
void selfer()
{
int i, j;
for (i=1 ; i<=1000000 ; i++)
{
if (!ver[i])
{
printf("%d\n",i);
for (j=i+digSum(i) ; j<=1000000 ; j+=digSum(j))
{
if (ver[j])
break;
ver[j]=true;
}
}
}
}
int main()
{
int i;
selfer();
return 0;
}
Tuesday, August 23, 2011
[UVa] 640 - Self Numbers
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Method: The problem at first glance seems too straightforward but it's not that much. Think a bit about the lines "Erin can add ...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.