要注意运算的最大范围不超界就离谱
#include <iostream> #include<bits/stdc++.h> using namespace std; const int mod = 1e7+9; #define int long long signed main() { int m,f,s,sec=1,fir=1; for(int i=0;i<2;i++) { cin >> m; while(m --) { cin>> f >> s; if(f == 1) sec = sec*s%mod; else fir = fir*s%mod; } swap(sec,fir); //交换乘除看两边的乘除运算是否相等 } cout<<(sec == fir ? "YES":"NO"); }