花神游历各国
#include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<cmath> #define maxn 5000100 using namespace std; typedef long long ll; ll tree[maxn]; ll arr[maxn]; int vis[maxn]; int root = 1; int push_down(int node, int be, int en) { if (be == en) { tree[node] = sqrt(tree[node]); if (tree[node] == 1 || tree[node] == 0) vis[node] = 1; return 0; } int l = 2 * node; int r = 2 * node + 1; int mid = (be + en) / 2; if(!vis[l]) push_down(l, be, mid); if(!vis[r]) push_down(r, mid + 1, en); tree[node] = tree[l] + tree[r]; if (vis[l] && vis[r]) vis[node] = 1; } ll update(int node, int