问题 A: 多项式输出

题目描述
一元 n 次多项式可用如下的表达式表示:
其中,aixi称为 i 次项,ai 称为 i 次项的系数。给出一个一元多项式各项的次数和系数,请按照如下规定的格式要求输出该多项式:
f(x)=anxn+an-1xn-1+…+a1x+a0,an≠0

  1. 多项式中自变量为 x,从左到右按照次数递减顺序给出多项式。
  2. 多项式中只包含系数不为 0 的项。
  3. 如果多项式 n 次项系数为正,则多项式开头不出现“+”号,如果多项式 n 次项系数为负,则多项式以“-”号开头。
  4. 对于不是最高次的项,以“+”号或者“-”号连接此项与前一项,分别表示此项系数为正或者系数为负。紧跟一个正整数,表示此项系数的绝对值(如果一个高于 0 次的项,其系数的绝对值为 1,则无需输出 1)。如果 x 的指数大于 1,则接下来紧跟的指数部分的形式为“x^b”,其中 b 为 x 的指数;如果 x 的指数为 1,则接下来紧跟的指数部分形式为“x”;
    如果 x 的指数为 0,则仅需输出系数即可。
  5. 多项式中,多项式的开头、结尾不含多余的空格。
    输入
    输入共有 2 行
    第一行 1 个整数,n,表示一元多项式的次数。
    第二行有 n+1 个整数,其中第 i 个整数表示第 n-i+1 次项的系数,每两个整数之间用空格隔开。(0<=n<=100,-100<=系数<=100)
    输出
    输出共 1 行,按题目所述格式输出多项式。
    样例输入 Copy
    5
    100 -1 1 -3 0 10
    样例输出 Copy
    100x5-x4+x3-3x2+10

模拟题,没啥好说的,慢慢写判断就行

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn,sum,x,y;
map<int,int>mp;
int a[N],s1[N],s2[N];
void solve(){cin >> n;for( int i=n;i>=0;i--){cin >> x;if(x==0)  {continue;}if(i!=n&&x>0&&y)          cout<<"+"; if(x<-1||x>1||i==0)     cout<<x;  if(x==-1&&i)           cout<<"-";      if(i==1)               cout<<"x"; if(i>1)               cout<<"x^"<<i; y++;}
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 B: 分数线划定

题目描述
世博会志愿者的选拔工作正在 A 市如火如荼的进行。为了选拔最合适的人才,A 市对所有报名的选手进行了笔试,笔试分数达到面试分数线的选手方可进入面试。面试分数线根据计划录取人数的150%划定,即如果计划录取m名志愿者,则面试分数线为排名第m*150%
(向下取整)名的选手的分数,而最终进入面试的选手为笔试成绩不低于面试分数线的所有选手。

现在就请你编写程序划定面试分数线,并输出所有进入面试的选手的报名号和笔试成绩。
输入
第一行,两个整数 n,m(5 ≤ n ≤ 5000,3 ≤ m ≤ n),中间用一个空格隔开,其中 n 表示报名参加笔试的选手总数,m 表示计划录取的志愿者人数。输入数据保证 m*150%向下取整后小于等于 n。
第二行到第 n+1 行,每行包括两个整数,中间用一个空格隔开,分别是选手的报名号 k(1000 ≤ k ≤ 9999)和该选手的笔试成绩 s(1 ≤ s ≤ 100)。数据保证选手的报名号各不相同。
输出
第一行,有两个整数,用一个空格隔开,第一个整数表示面试分数线;第二个整数为进入面试的选手的实际人数。
从第二行开始,每行包含两个整数,中间用一个空格隔开,分别表示进入面试的选手的报名号和笔试成绩,按照笔试成绩从高到低输出,如果成绩相同,则按报名号由小到大的顺序输出。
样例输入 Copy
6 3
1000 90
3239 88
2390 95
7231 84
1005 95
1001 88
样例输出 Copy
88 5
1005 95
2390 95
1000 90
1001 88
3239 88

思路:排序,然后先找到第m*1.5这个人的分数,然后看有没有同分的,接着把这些人输出就行

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=1e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn;
map<int,int>mp;
struct Node{int xh;int s;}a[N];
bool cmp(Node a,Node b){if(a.s == b.s) return a.xh < b.xh;return a.s > b.s;
}
void solve(){cin >> n >> m;m = m * 1.5;for(int i = 1 ; i <= n ; i ++ ) cin >> a[i].xh >> a[i].s;sort(a+1,a+1+n,cmp);int minn = a[m].s;for(int i = m + 1; i <= n ; i ++ )if(a[i].s == minn) m++;else break;cout<<minn<<" "<<m<<"\n";for(int i = 1 ; i <= m ; i ++) cout<<a[i].xh<<" "<<a[i].s<<"\n";
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 C: 细胞分裂

题目描述
Hanks 博士是 BT (Bio-Tech,生物技术) 领域的知名专家。现在,他正在为一个细胞实验做准备工作:培养细胞样本。

Hanks 博士手里现在有 N 种细胞,编号从 1~N,一个第 i 种细胞经过 1 秒钟可以分裂为Si个同种细胞(Si为正整数)。现在他需要选取某种细胞的一个放进培养皿,让其自由分裂,进行培养。一段时间以后,再把培养皿中的所有细胞平均分入 M 个试管,形成 M 份样本,用于实验。Hanks 博士的试管数 M 很大,普通的计算机的基本数据类型无法存储这样大的M 值,但万幸的是,M 总可以表示为 m1的 m2次方,即M = m1^m2,其中 m1,m2均为基本数据类型可以存储的正整数。

注意,整个实验过程中不允许分割单个细胞,比如某个时刻若培养皿中有 4 个细胞,Hanks 博士可以把它们分入 2 个试管,每试管内 2 个,然后开始实验。但如果培养皿中有 5个细胞,博士就无法将它们均分入 2 个试管。此时,博士就只能等待一段时间,让细胞们继续分裂,使得其个数可以均分,或是干脆改换另一种细胞培养。

为了能让实验尽早开始,Hanks 博士在选定一种细胞开始培养后,总是在得到的细胞“刚好可以平均分入 M 个试管”时停止细胞培养并开始实验。现在博士希望知道,选择哪种细胞培养,可以使得实验的开始时间最早。
输入
共有三行。
第一行有一个正整数 N(1 ≤N≤ 10000),代表细胞种数。
第二行有两个正整数 m1,m2(1 ≤m1 ≤ 30000,1 ≤m2 ≤ 10000),以一个空格隔开, m1m2即表示试管的总数M。
第三行有 N 个正整数,第i 个数Si(1 ≤ Si ≤ 2,000,000,000) 表示第i 种细胞经过1 秒钟可以分裂成同种细胞的个数。
输出
共一行,为一个整数,表示从开始培养细胞到实验能够开始所经过的最少时间(单位为秒)。
如果无论 Hanks 博士选择哪种细胞都不能满足要求,则输出整数-1。
样例输入 Copy
1
2 1
3
样例输出 Copy
-1
提示
经过 1 秒钟,细胞分裂成 3 个,经过 2 秒钟,细胞分裂成 9 个,……,可以看出无论怎么分裂,细胞的个数都是奇数,因此永远不能分入 2 个试管。

思路:分解质因数
小tips:m1^n ,不论n多大,质因数永远只有m1
所以我们可以先将m1进行质因数分解
然后枚举i,对第i个细胞进行质因数分解,如果容器能包含所有si的质因数那就更新最大值

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,m1,m2,maxn,ans;
int f[N];
int s[N],p[N];
int t = 2;
void solve(){cin >> n >> m1 >> m2;for(int i = 1 ; i <= n ; i ++ ) cin >> s[i];if(m1 == 1){cout<<"0\n";return ;}while(m1 != 1){while(m1%t == 0) m1 /= t , p[t]++;maxn = max(maxn,t);p[t++]*=m2;}ans = inf;for(int i = 1 ; i <= n ; i ++ ){int l = 0;for(int j = 2 ; j <= maxn ; j ++ ){if(!p[j]) continue;int c = 0;while(s[i] % j == 0) s[i]/=j,c++;if(c == 0) {l = inf ; break;}l = max(l,(p[j]-1)/c);}ans = min(ans,l);}if(ans >= inf) cout<<-1<<"\n";else cout<<ans+1;
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 D: 道路游戏

题目描述
小新正在玩一个简单的电脑游戏。
游戏中有一条环形马路,马路上有 n 个机器人工厂,两个相邻机器人工厂之间由一小段马路连接。小新以某个机器人工厂为起点,按顺时针顺序依次将这 n 个机器人工厂编号为1~n,因为马路是环形的,所以第 n 个机器人工厂和第 1 个机器人工厂是由一段马路连接在一起的。小新将连接机器人工厂的这 n 段马路也编号为 1~n,并规定第 i 段马路连接第 i 个机器人工厂和第 i+1 个机器人工厂(1≤i≤n-1),第 n 段马路连接第 n 个机器人工厂和第 1个机器人工厂。
游戏过程中,每个单位时间内,每段马路上都会出现一些金币,金币的数量会随着时间发生变化,即不同单位时间内同一段马路上出现的金币数量可能是不同的。小新需要机器人的帮助才能收集到马路上的金币。所需的机器人必须在机器人工厂用一些金币来购买,机器人一旦被购买,便会沿着环形马路按顺时针方向一直行走,在每个单位时间内行走一次,即从当前所在的机器人工厂到达相邻的下一个机器人工厂,并将经过的马路上的所有金币收集给小新,例如,小新在 i(1≤i≤n)号机器人工厂购买了一个机器人,这个机器人会从 i 号机器人工厂开始,顺时针在马路上行走,第一次行走会经过 i 号马路,到达 i+1 号机器人工厂(如果 i=n,机器人会到达第 1 个机器人工厂),并将 i 号马路上的所有金币收集给小新。 游戏中,环形马路上不能同时存在 2 个或者 2 个以上的机器人,并且每个机器人最多能够在环形马路上行走 p 次。小新购买机器人的同时,需要给这个机器人设定行走次数,行走次数可以为 1~p 之间的任意整数。当马路上的机器人行走完规定的次数之后会自动消失,小新必须立刻在任意一个机器人工厂中购买一个新的机器人,并给新的机器人设定新的行走次数。
以下是游戏的一些补充说明:
游戏从小新第一次购买机器人开始计时。
购买机器人和设定机器人的行走次数是瞬间完成的,不需要花费时间。
购买机器人和机器人行走是两个独立的过程,机器人行走时不能购买机器人,购买完机器人并且设定机器人行走次数之后机器人才能行走。
在同一个机器人工厂购买机器人的花费是相同的,但是在不同机器人工厂购买机器人的花费不一定相同。
购买机器人花费的金币,在游戏结束时再从小新收集的金币中扣除,所以在游戏过程中小新不用担心因金币不足,无法购买机器人而导致游戏无法进行。也因为如此,游戏结束后,收集的金币数量可能为负。
现在已知每段马路上每个单位时间内出现的金币数量和在每个机器人工厂购买机器人需要的花费,请你告诉小新,经过 m 个单位时间后,扣除购买机器人的花费,小新最多能收集到多少金币。
输入
第一行 3 个正整数,n,m,p,意义如题目所述。
接下来的 n 行,每行有 m 个正整数,每两个整数之间用一个空格隔开,其中第 i 行描述了 i 号马路上每个单位时间内出现的金币数量(1≤金币数量≤100),即第 i 行的第 j(1≤j≤m)个数表示第 j 个单位时间内 i 号马路上出现的金币数量。
最后一行,有 n 个整数,每两个整数之间用一个空格隔开,其中第 i 个数表示在 i 号机器人工厂购买机器人需要花费的金币数量(1≤金币数量≤100)。
输出
共一行,包含 1 个整数,表示在 m 个单位时间内,扣除购买机器人花费的金币之后,小新最多能收集到多少金币。
样例输入 Copy
2 3 2
1 2 3
2 3 4
1 2
样例输出 Copy
5

思路:f[i]:第i秒获得的最大钱数
转移方程 f[i] = max(f[i],f[i-k] - a[last] + sum) 1<=k<=p
a[i] : 第i个工厂的机器人的费用
sum是到第k秒内所有的金币数 然后每次减去第last个工厂的价格
如果i-k 就break 因为时间不能为负数
总结 枚举时间i 1~m
枚举工厂j 1~n
对于第i时间下第j个工厂枚举所有满足的k 1~max(i,p)
更新f[i]的值
输入f[m]即为最大值 时间复杂度为O(n^3)

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn,sum,x,y,p;
int f[N];
int a[N];
int b[1005][1005];
void solve(){cin >> n >> m >> p;memset(f,-inf,sizeof f);f[0] = 0;for(int i = 1 ; i <= n ; i ++)for(int j = 1 ; j <= m ; j ++)cin >> b[i][j];for(int i = 1 ; i <= n ; i ++ ) cin >> a[i];for(int i = 1 ; i <= m ; i ++ )for(int j = 1 ; j <= n ; j ++ ){int ff = j - 1;if(!ff) ff = n;int ss = b[ff][i];for(int k = 1 ; k <= p ; k ++){if(i-k < 0) break;f[i] = max(f[i],f[i-k] + ss - a[ff]);ff--;if(!ff)  ff = n;ss += b[ff][i-k];}}cout<<f[m];}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 E: Sharing Cookies

题目描述
Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Constraints
1≤A,B≤100
Both A and B are integers.
输入
Input is given from Standard Input in the following format:
A B
输出
If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.
样例输入 Copy
4 5
样例输出 Copy
Possible
提示
If Snuke gives nine cookies, each of the three goats can have three cookies.

思路:只要a,b ,a+b有一个能被三整除就是Possible,否则就是Impossible
不要单纯的以为只是a+b

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=1e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn;
map<int,int>mp;
int a[N],b[N],s[N];void solve(){cin >> n >> m;if((n+m)%3 == 0 || n % 3 == 0 || m % 3 == 0) cout<<"Possible";else cout<<"Impossible";
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 F: Snake Toy

题目描述
Snuke has N sticks. The length of the i-th stick is li.
Snuke is making a snake toy by joining K of the sticks together.
The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.

Constraints
1≤K≤N≤50
1≤li≤50
li is an integer.
输入
Input is given from Standard Input in the following format:
N K
l1 l2 l3 … lN
输出
Print the answer.
样例输入 Copy
5 3
1 2 3 4 5
样例输出 Copy
12
提示
You can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.

思路:降序排序,累计前k个的值,输出

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=1e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn;
map<int,int>mp;
int a[N],b[N],s[N];void solve(){cin >> n >> m;for(int i = 1 ; i <= n ; i ++ ) cin >> a[i];sort(a+1,a+1+n,greater<int>());for(int i = 1 ; i <= m ; i++)ans+=a[i];cout<<ans;
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 G: Splitting Pile

题目描述
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer ai written on it.
They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.
Let the sum of the integers on Snuke’s cards and Raccoon’s cards be x and y, respectively. They would like to minimize |x−y|. Find the minimum possible value of |x−y|.

Constraints
2≤N≤2×105
−109≤ai≤109
ai is an integer.
输入
Input is given from Standard Input in the following format:
N
a1 a2 … aN
输出
Print the answer.
样例输入 Copy
6
1 2 3 4 5 6
样例输出 Copy
1
提示
If Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x−y|=1. This is the minimum possible value.

思路:考虑前缀和和后缀和,枚举i然后每次判断前缀和i和后缀和i的abs,更新最大值,这里后缀和可以不用另外开一个数组,直接总和-当前的前缀和即可,注意枚举是1~n-1而不是1 ~ n

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn,sum;
map<int,int>mp;
int a[N],s1[N],s2[N];
void solve(){ans = 2e17;cin >> n;for(int i = 1 ; i <= n ; i ++ ) cin >> a[i],sum+=a[i];for(int i = 1 ; i <= n ; i ++ ) s1[i] = s1[i-1] + a[i];for(int i = n ; i >= 1 ; i -- ) s2[i] = s2[i+1] + a[i];for(int i = 1 ; i < n ; i ++ ){ans = min(ans,abs(sum-s1[i]-s1[i]));}cout<<ans;
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 H: Fennec VS. Snuke

题目描述
Fennec and Snuke are playing a board game.
On the board, there are N cells numbered 1 through N, and N−1 roads, each connecting two cells. Cell ai is adjacent to Cell bi through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.
Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored. Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell. More specifically, each player performs the following action in her/his turn:
Fennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.
Snuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.
A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.

Constraints
2≤N≤105
1≤ai,bi≤N
The given graph is a tree.
输入
Input is given from Standard Input in the following format:
N
a1 b1
:
aN−1 bN−1
输出
If Fennec wins, print Fennec; if Snuke wins, print Snuke.
样例输入 Copy
7
3 6
1 2
3 1
7 4
5 7
1 4
样例输出 Copy
Fennec
提示
For example, if Fennec first paints Cell 2 black, she will win regardless of Snuke’s moves.

思路:考虑BFS,因为题目说了1和n一开始已经分别染了不同白和黑,那么我们就只要看从1能染多少个色,和从n能染多少色,谁多输出对应的哪个人

#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map># define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=1e9+7;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);int T,n,m,l,r,d,ans,maxn,sum,x,y;
vector<int>g[N];
int vis[N];
int cnt_F,cnt_S;void bfs(){queue<int>q;q.push(1);q.push(n);vis[1] = 1 ; vis[n] = -1;while(q.size()){auto x = q.front();q.pop();for(auto i : g[x]){int y = i;if(!vis[y]){vis[y] = vis[x];if(vis[y] == -1) cnt_S++;else cnt_F++;q.push(y);}}}
}
void solve(){cin >> n;for(int i = 1 ; i < n ; i ++ ){int u,v;cin >> u >> v;g[u].push_back(v);g[v].push_back(u);}bfs();cout<<(cnt_F>cnt_S?"Fennec":"Snuke");
}
/**/
signed main(){  std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); // cin >> T;T = 1;while(T--){solve();} return 0;
}

问题 I: Mole and Abandoned Mine

不会写,下次一定。

2021级新生个人训练赛第40场相关推荐

  1. Contest3145 - 2021级新生个人训练赛第37场_A: 奖品

    // 问题 A: 奖品 时间限制: 1.000 Sec 内存限制: 128 MB题目描述 托塔李天王的三太子那吒,本领高强,他要赶在奥林匹克运动会之际,开一个头脑 奥林匹克比赛,获胜者的奖品就是经过提 ...

  2. Contest3143 - 2021级新生个人训练赛第36场_B: 数字游戏

    // 问题 B: 数字游戏 时间限制: 1.000 Sec 内存限制: 512 MB题目描述 有一天,小明给佳佳出了一道题, 给出一个正整数n,佳佳可以进行如下三种操作: 1.使n减去1 2.如果n是 ...

  3. 2021级新生个人训练赛第36场

    问题 A: 礼物 题目描述 在一个n×n的网格图上,放置着m个礼物,每个礼物有一个价值vi(1≤i≤m),你可以选择一个礼物,然后选择: (1)取走与它同列的所有礼物,或者(2)取走与它同行的所有礼物 ...

  4. Contest3121 - 2021级新生个人训练赛第26场_问题 F: 乐乐的数字

    // 问题 F: 乐乐的数字 时间限制: 1.000 Sec 内存限制: 128 MB题目描述 乐乐做完数学作业,突发奇想定义了一种新的数:乐乐数.乐乐把n个数排成一行,一个数的"乐乐数&q ...

  5. 2021级新生个人训练赛第38场

    问题 A: chicken 题目描述 小 x 非常喜欢小鸡翅.他得知 NSC 超市为了吸引顾客,举行了如下的活动: 一旦有顾客在其他超市找到更便宜的小鸡翅,NSC 超市将免费送给顾客 1000g 小鸡 ...

  6. Contest3117 - 2021级新生个人训练赛第24场_问题 E: 打印方阵

    问题 E: 打印方阵 时间限制: 1.000 Sec 内存限制: 128 MB题目描述 下面这样的方阵很有规律,称为蛇形方阵.例如3*3的: 1 2 3 6 5 4 7 8 9 现在给定边长,输出相应 ...

  7. Contest3125 - 2021级新生个人训练赛第27场_问题 F: 兔子

    //问题 F: 兔子 时间限制: 1.000 Sec 内存限制: 128 MB题目描述 从左往右有100000001个整数点,分别是整数点0至整数点100000000.有n只兔子,第i只兔子在整数点d ...

  8. [2021.11.19]UPC-2021级新生个人训练赛第4场-19278 Problem D 关门

    题目描述 为了将这些生产的玩具销往海外,晚上江北的玩具公司灯火通明.安安是公司的保安,当所有工作人员离开公司后,他要把公司里所有的门都关闭.房间的门有些是关闭的,有些是打开的.为了察看该公司里所有房间 ...

  9. [2022.1.13]UPC-2021级新生个人训练赛第22场-9783 Problem H 铺地砖

    问题 H: 铺地砖 时间限制: 1.000 Sec 内存限制: 128 M 题目描述 一天,晨晨的数学老师布置了一道题目,大意如下:用1×1和2×2的磁砖不重叠地铺满n×3的地板,共有多少种方案? 例 ...

最新文章

  1. static和global的区别
  2. php纯面向过程--论坛
  3. scala 字符串转换数组_如何在Scala中将十六进制字符串转换为字节数组?
  4. 动态加载html 添加样式表,使页面动态加载不同CSS样式表,从而实现不同风格模板的方法...
  5. Java 身份证工具类
  6. linux下批量下载站点内容初稿
  7. ubuntu16.04下ROS操作系统学习笔记(八)机器人SLAM与 Gmapping-Hector_slam-Cartographer--ORB_SLAM
  8. java热血_5个让人热血沸腾的java项目
  9. 线程安全的list之synchronizedList和CopyOnWriteArrayList
  10. gtShell - 为你常用的目录建立标签并快速跳转
  11. 不确定性原理的前世今生 · 数学篇(一)
  12. 在MT4上使用双线MACD指标源码
  13. MLDN Java学习笔记(4)
  14. 计算机硬盘和分区是什么关系,电脑硬盘如何分区 电脑硬盘分区注意事项【详解】...
  15. 如何用电路实现检测过零点?这个简单电路就能搞定
  16. 网口扫盲三:以太网芯片MAC和PHY的关系
  17. 用云服务器架设好服务器显示无法连接
  18. android通讯录开发二 数据表各字段含义
  19. 树莓派4通过华为ME909S 4G模块连接蜂窝网(非PPP)
  20. matlab——GUI概念

热门文章

  1. Mor.ai蓦然认知重磅推出智能家居IoT解决方案
  2. 【硬核扫盲】到底什么是相干光通信?
  3. C++实现找100(任意)以内的质数--非常好的算法
  4. BZOJ4887:[TJOI2017]可乐(矩阵乘法)
  5. 钉钉,腾讯会议中使用虚拟人物形象上网课
  6. 微信、QQ等第三方账号登录的具体思路
  7. 用计算机模拟地球诞生,计算机模拟显示:地球生命或源自太空外星微生物
  8. ATJ2157ATJ2127音乐按文件名拼音排序---标案是按内码进行排序
  9. 利用MAT进行内存泄漏分析
  10. python 自动化输入登录密码_selenium+python实现自动登录脚本