# Groundhog and 2-Power Representation

s = input()
a = []
for i in range(len(s)):
if s[i] == '(':
a.append(-1)
elif s[i] == ')':
a.append(-2)
elif s[i] == '+':
a.append(-3)
else:
a.append(int(s[i]))
stack = []
for i in range(len(a)):
if a[i] != -2:
stack.append(a[i])
else:  # a[i]==)
while len(stack) != 0:
x = stack.pop()
if len(stack) == 0:
stack.append(x)
break
else:
op = stack.pop()
if op == -1:  # (
x = pow(stack.pop(), x)
stack.append(x)
break
else:  # op==-3 +
y = stack.pop()
stack.append(x + y)
while len(stack) != 0:
x = stack.pop()
if len(stack) != 0:
stack.pop()
y = stack.pop()
stack.append(x + y)
else:
stack.append(x)
break
print(stack.pop())


print(eval(input().replace('(', '**(')))


Groundhog and Apple Tree
Groundhog and Gaming Time
Groundhog and Golden Apple

# Groundhog Chasing Death

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;

ll qpow(ll a, ll b) {
a %= mod;
ll res = 1;
while (b) {
if (b & 1)res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}

ll a, b, c, d, x, y;
map<int, int> mp;//记录x里质因数p的个数
ll res = 1;
ll phi = mod - 1;

// 统计答案
void statisticsRes(ll p, ll cntX, ll cntY) {
ll a1 = a * cntX, b1 = b * cntX;
ll c1 = c * cntY, d1 = d * cntY;

ll sum = 0;
for (ll j = a1; j <= b1; j += cntX) {
// 只取< 等于再下面那个for里统计
if (j < c1)
sum += (d1 / cntY - (c1 - 1) / cntY) * j;
else if (j < d1)
sum += (d1 / cntY - j / cntY) * j;

sum %= phi;
}

for (ll j = c1; j <= d1; j += cntY) {
// <=
if (j <= a1)
sum += (b1 / cntX - (a1 - 1) / cntX) * j;
else if (j <= b1)
sum += (b1 / cntX - j / cntX + (((j - a1) % cntX) == 0)) * j;

sum %= phi;
}
sum = sum % phi + phi;
res = res * qpow(p, sum) % mod;
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> a >> b >> c >> d >> x >> y;

for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
int cnt = 0;
while (x % i == 0) {
cnt++;
x /= i;
}
mp[i] = cnt;
}
}
if (x > 1)  mp[x] = 1;

for (int i = 2; i * i <= y; i++) {
if (y % i == 0) {
int cnt = 0;
while (y % i == 0) {
cnt++;
y /= i;
}
if (mp.count(i))
statisticsRes(i, mp[i], cnt);
}
}

if (y > 1 && mp.count(y))
statisticsRes(y, mp[y], 1);

cout << res << endl;
return 0;
}


# Groundhog Looking Dowdy

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e6 + 10;
int n, m, k;

vector<pii> a;
int len;
int vis[N];

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> n >> m;
for (int i = 1, x; i <= n; i++) {
cin >> k;

for (int j = 1; j <= k; j++) {
cin >> x;
a.push_back({x, i});
}
}

sort(a.begin(), a.end());
len = a.size();

int cnt = 0;
int res = INT_MAX;
for (int r = 0, l = 0; r < len; r++) {
vis[a[r].second]++;
if (vis[a[r].second] == 1) {
cnt++;
}

while (l < r && cnt >= m) {
res = min(res, a[r].first - a[l].first);
vis[a[l].second]--;
if (!vis[a[l].second]) cnt--;
l++;
}
}

cout << res << endl;
return 0;
}


Groundhog Playing Scissors
Groundhog Speaking Groundhogish

# The Crime-solving Plan of Groundhog

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e6 + 10;
int n;

vector<int> mul(vector<pii> a, int b) {
vector<int> c;
int t = 0;

for (int i = a.size() - 1; i >= 0; i--) {
int x = a[i].first;
int cnt = a[i].second;

for (int j = 0; j < cnt; j++) {
t += x * b;
c.push_back(t % 10);
t /= 10;
}
}
while (t)c.push_back(t % 10), t /= 10;
return c;
}

void output(vector<int> a) {
for (int i = a.size() - 1; i >= 0; i--)
cout << a[i];//注意了 输出的是一串数 所以不能有空格
cout << endl;
}

int a[N];
vector<pii> v;

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int T;
cin >> T;
while (T--) {
for (int i = 0; i <= 9; i++) {
a[i] = 0;
}
v.clear();

cin >> n;
for (int i = 1, x; i <= n; i++) {
cin >> x;
a[x]++;
}

int x;
for (int i = 1; i <= 9; i++) {
if (a[i]) {
x = i;
a[i]--;
break;
}
}
for (int i = 1; i <= 9; i++) {
if (a[i]) {
if (v.empty()) {
v.push_back({i, 1});
a[i]--;
if (a[0]) v.push_back({0, a[0]});
if (a[i]) v.push_back({i, a[i]});
} else {
v.push_back({i, a[i]});
}
}
}
output(mul(v, x));
}
return 0;
}


# The Escape Plan of Groundhog

#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
vector<int> e[N];
int n, m, t;

int fa[N];

void dfs1(int u, int f) {
fa[u] = f;
for (int i = 0, lim = e[u].size(); i < lim; i++) {
int v = e[u][i];
if (v != f) {
dfs1(v, u);
}
}
}

vector<int> path;
int st = 0;
int res = 0;

void dfs2(int u, int f, int k, int x, int y) {

if (u == n) return;

int t1 = (y + 1) / 2;
int t2 = x;

if (t1 <= t2) { // 到达该点被抓
res = max(t1, res);
return;
}

int path_v = k ? path[k] : 0;//判断是否是 st-n 上的点
int lim = e[u].size();
for (int i = 0; i < lim; i++) {
int v = e[u][i];
if (v != f && v != path_v) {
dfs2(v, u, 0, x + 1, y + 1);
}
}

// 停在这个位置等待被抓
if (lim == 1) {
res = max(res, (y + 1) / 2);
}
if (k) {
dfs2(path_v, u, k + 1, x + 1, max(y - 1, 0));
}
}

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

cin >> n >> t;
for (int i = 1, u, v; i < n; i++) {
cin >> u >> v;
e[u].push_back(v);
e[v].push_back(u);
}

dfs1(1, 0);

for (int i = n; i; i = fa[i]) {
path.push_back(i);
}

m = path.size() - 1;
if (m <= t) {
cout << 0 << endl;
return 0;
}

//翻转
reverse(path.begin(), path.end());
//起始点
st = path[t];
dfs2(st, 0, t + 1, 0, m - t);

cout << res << endl;
return 0;
}


The Flee Plan of Groundhog
The Shopping Plan of Groundhog

03-15 4488

08-10 312
11-13 420