原题链接:
https://vjudge.net/problem/Kattis-remainderreminder
https://open.kattis.com/problems/remainderreminder
AC代码:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
const int INF = 0x3fffffff;
typedef long long ll;
typedef unsigned long long ull;
void __init__()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
}
int a, b, c, d, e, f, g;
vector<int> siz;
int main()
{
__init__();
cin >> a >> b >> c >> d >> e >> f >> g;
for (int i = 1; i * 2 < a; i++)
{
siz.push_back((a - i * 2) * (b - i * 2) * i);
}
sort(siz.begin(), siz.end());
int v1 = siz[siz.size() - 1];
int v2 = siz[siz.size() - 2];
int v3 = siz[siz.size() - 3];
for (int i = 0; i <= g / v1; i++)
{
ll ans = i * v1 + c;
if (ans < f)
{
continue;
}
if (ans % v2 == d && ans % v3 == e)
{
cout << ans << endl;
break;
}
}
return 0;
}
看了赛后题解说是用CRT(中国剩余定理),好像确实是典型的拓展CRT模板题,但就这道题来说,不用CRT也能做,暴就完了(doge
不过既然遇到了CRT的题了还是好好学学吧,但凡时间上要求的严一点暴就过不去了Orz