好像也没啥说的。
1316 | Accepted | 248K | 0MS | C++ | 868B |
/*
ID: thestor1
LANG: C++
TASK: poj1316
*/
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cassert>
using namespace std;
const int MAXN = 10000;
int next(int n)
{
int r = n;
while (n)
{
r += n % 10;
n /= 10;
}
return r;
}
int main()
{
std::ios::sync_with_stdio(false);
std::vector<bool> self(MAXN, true);
for (int i = 1; i < MAXN; ++i)
{
int c = i, n;
while (true)
{
n = next(c);
if (n == c || !self[n])
{
break;
}
self[n] = false;
c = n;
}
}
for (int i = 1; i < MAXN; ++i)
{
if (self[i])
{
cout << i << endl;
}
}
return 0;
}