RT,代码如下qwq.
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <map>
#define Heriko return
#define Deltana 0
#define Romanno 1
#define S signed
#define LL long long
#define R register
#define I inline
#define CI const int
#define mst(a, b) memset(a, b, sizeof(a))
#define ON std::ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
template<typename J>
I void fr(J &x)
{
short f(1);
char c=getchar();
x=0;
while(c<'0' or c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while (c>='0' and c<='9')
{
x=(x<<3)+(x<<1)+(c^=48);
c=getchar();
}
x*=f;
}
template<typename J>
I void fw(J x,bool k)
{
x=(x<0?putchar('-'),-x:x);
static short stak[35];
short top(0);
do
{
stak[top++]=x%10;
x/=10;
}
while(x);
while(top) putchar(stak[--top]+'0');
if(k) putchar('\n');
else putchar(' ');
}
CI MXX=1005,NXX=8e7+5;
I LL Gcd(LL x,LL y){Heriko !y?x:Gcd(y,x%y);}
I LL Lcm(LL x,LL y){Heriko (x*y)/Gcd(x,y);}
LL n,k;
struct Order
{
LL t,x,y;
}
co[MXX];
struct List
{
LL val,a,b;
}
ko[NXX];
LL cnt;
I bool Cmp(const List &x,const List &y) {Heriko x.val<y.val;}
S main()
{
fr(n),fr(k);
for(R int i(1);i<=k;++i) fr(co[i].t),fr(co[i].x),fr(co[i].y);
for(R int i(1);i<=k;++i)
for(R int j(i+1);j<=k;++j)
ko[++cnt]=(List){Lcm(co[i].t,co[j].t),i,j};
sort(ko+1,ko+1+cnt,Cmp);
for(R LL i(1);i<=cnt;++i)
{
if(ko[i].val<=0) continue;
LL a(ko[i].a),b(ko[i].b);
LL va((n+co[a].x+((ko[i].val/co[a].t)-1)*co[a].y)%n);
LL vb((n+co[b].x+((ko[i].val/co[b].t)-1)*co[b].y)%n);
if(va!=vb)
{
fw(ko[i].val-1,1);
Heriko Deltana;
}
}
puts("Mystia will cook forever...");
Heriko Deltana;
}
评测出来是这样的,有两个 WA(
大约因为我比较菜于是没有想出来哪个地方有问题,希望大佬不要嫌弃我马蜂奇怪。