#include<bits/stdc++.h>usingnamespace std ;constint N =1e6+10;int st[N], f[N];intfather(int x){if(f[x]!= x) f[x]=father(f[x]);return f[x];}intmain(){int n ,m ;
cin >> n >> m ;for(int i =1; i <= n; i ++) f[i]= i ;int flag =0;while(m --){int a, b ;
cin >> a >> b ;int fa =father(a);int fb =father(b);
st[a]++, st[b]++;if(fa == fb){//a和b相邻 a和c相邻 b就不能和c相邻
cout <<"No"<< endl ;
flag =1;break;}
f[fa]= fb ;}if(flag)return0;for(int i =1; i <= n; i ++){if(st[i]>2){//相邻的元素不超过2个
cout <<"No"<< endl ;return0;}}
cout <<"Yes"<< endl ;return0;}
E
#include<bits/stdc++.h>usingnamespace std ;longlong n ,x ;constint N =110;longlong a[N], d[N], f[N][2];intmain(){
cin >> n >> x ;for(int i = n; i >=1; i --) cin >> a[i];for(int i =1; i <= n; i ++){
d[i]= x / a[i];
x %= a[i];}//自动机//f[i][0]指的是当前所需的最小个数//f[i][1]指的是如果多一个当前硬币的最小个数 for(int i =1; i <= n; i ++){if(i ==1){
f[i][0]= d[i];
f[i][1]= d[i]+1;}else{longlong k = a[i -1]/ a[i];
f[i][0]= d[i]+ f[i -1][0];
f[i][0]=min(f[i][0], k - d[i]+ f[i -1][1]);
f[i][1]= d[i]+1+ f[i -1][0];
f[i][1]=min(f[i][1], k - d[i]-1+ f[i -1][1]);}}
cout << f[n][0]<< endl ;return0;}
D#include <bits/stdc++.h>using namespace std ;const int N = 1e6 + 10 ;int st[N], f[N] ;int father(int x) { if (f[x] != x) f[x] = father(f[x]) ; return f[x] ;}int main(){ int n ,m ; cin >> n >> m ; for (int i = 1; i <= n; i