显示代码纯文本
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 10;
#define is_num(x) (x <= '9' and x >= '0')
inline LL get_num() {
char tmp = getchar();
LL res = 0;
while (not is_num(tmp)) tmp = getchar();
while ( is_num(tmp)) {
res = (res << 3) + (res << 1) + tmp - '0';
tmp = getchar();
}
return res;
}
LL seq[maxn];
int app[maxn];
int n;
inline void solve() {
n = get_num();
LL sum = 0;
app[0] = 1;
for (int i = 1; i <= n; i++) {
seq[i] = get_num();
// if(not seq[i]) continue;
sum = (sum + seq[i]) % n;
if (app[sum]) {
for (int j = app[sum]; j <= i; j++) {
printf("%lld ", seq[j]);
}
printf("\n");
return;
}
app[sum] = i + 1;
}
printf("Tree in Tree with chairman tree.\n");
}
int main() {
freopen("A_long_name_without_mean.in", "r", stdin);
freopen("A_long_name_without_mean.out", "w", stdout);
solve();
return 0;
}