作者:维生素-熙 | 来源:互联网 | 2023-07-07 08:48
可以像筛选法那样标记但是内存最多只能开1024的int数组我用了位优化用一个int32位标记32个数字接下来就离线排个序算出第k大的哪个数#include#include#
可以像筛选法那样标记 但是内存最多只能开1024的int数组 我用了位优化 用一个int 32 位标记32个数字 接下来就离线 排个序 算出第k大的哪个数
#include
#include
#include
using namespace std;
int a[10000000/32];
struct node
{
int x, y, id;
}b[50010];
int get(int x)
{
int ans = x;
while(x)
{
ans += x%10;
x /= 10;
}
return ans;
}
void dfs(int x)
{
int tmp = x + get(x);
if(tmp > 10000000 || a[tmp])
return;
a[tmp] = 1;
dfs(tmp);
}
bool cmp1(node a, node b)
{
return a.x
SGU 108. Self-numbers 2 离线+位优化