AtCoder Beginner Contest 259 E

LCM为所有最高幂次的质因子的乘积
#include<bits/stdc++.h>
using namespace std;

#define fr first
#define se second
#define et0 exit(0);
#define rep(i, a, b) for(int i = (a); i <= (b); i ++)
#define rrep(i, a, b) for(int i = (a); i >= (b); i --)

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef unsigned long long ULL;

const int INF = 0X3f3f3f3f, N = 2e5 + 10, MOD = 1e9 + 7;
const double eps = 1e-7, PI = 3.1415926;

vector<PII> primes[N];

unordered_map<int,int> st;
unordered_map<int,int> cnt;

void work() {
	int n;
	cin>>n;
	rep(i,1,n){
		int k;
		cin>>k;
		rep(j,1,k){
			int a,b;
			cin>>a>>b;
			primes[i].push_back({a,b});
			if(b>st[a]){
				st[a]=b;
				cnt[a]=1;
			}
			else if(b==st[a]) cnt[a]++;
		}
	}
	int res=1;
	rep(i,1,n){
		bool flag=false;
		rep(j,0,primes[i].size()-1){
			int cur=primes[i][j].fr,m=primes[i][j].se;
			if(st[cur]==m && cnt[cur]==1) flag=true;
		}	
		if(flag) res++;
	}
	cout<<(res==n+1?res-1:res)<<endl;
}

signed main() {
	
	work();
	
	return 0;
}
posted @ 2022-07-10 22:31  xhy666  阅读(32)  评论(0)    收藏  举报