40pts求助 有四个小点一直过不了
查看原帖
40pts求助 有四个小点一直过不了
545032
XY_world楼主2023/11/15 13:56
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,t[1005],x,y,color[1005],ans=1e18;
signed main(){
    cin>>n>>k;
    for(int i=1;i<=k;i++){
    	cin>>t[i]>>x>>y;
    	color[i]=(x+(i-1)*y)%n;
    	if(i==1) color[i]=x;
	}
	for(int i=1;i<k;i++){
		for(int j=i+1;j<=k;j++){
			if(color[i]!=color[j]) ans=min(ans,(t[i]*t[j]/__gcd(t[i],t[j])));
		    //cout<<i<<" "<<j<<" "<<ans<<endl;
		}
	}
	if(ans==1e18) cout<<"Mystia will cook forever...";
	else cout<<ans-1;
    return 0;
}
2023/11/15 13:56
加载中...