QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108651#5573. Holiday RegiftingLG_MonkeyCompile Error//C++141.1kb2023-05-25 21:53:542023-05-25 21:53:56

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-25 21:53:56]
  • 评测
  • [2023-05-25 21:53:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second 
#define deb(var) cerr << #var << '=' << (var) << "; "
#define ll long long
int n, m, c[10010];
const int mod = 998244353;
vector<int> g[10010]; ll ind[10010], ord[10010], f[10010]; 
signed main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> c[i];
	while (m--) {
		int u, v;
		cin >> u >> v; g[u].pb(v); ind[v]++;
	}
	ll ans = c[1];
	f[1] = ans;
	for (int j = 1; j <= n; j++) {
		int u = j;
		for (int k = 0; k < g[u].size(); k++) {
			int v = g[u][k];
			f[v] += f[u] / c[u];
		}
		f[u] %= c[u];
	}
	for (int i = 2; i <= n; i++) {
		int u = i;
		int o = c[u] / __gcd(f[u], c[u]);
		for (int u = 1; u <= n; u++) f[u] *= o;
		for (int j = 1; j <= n; j++) {
			int u = j;
			for (int k = 0; k < g[u].size(); k++) {
				int v = g[u][k];
				f[v] += f[u] / c[u];
			}
			f[u] %= c[u];
		}
		ans = ans * o % mod;
	}
	cout << ans;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:33:37: error: no matching function for call to ‘__gcd(long long int&, int&)’
   33 |                 int o = c[u] / __gcd(f[u], c[u]);
      |                                ~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:1199:5: note: candidate: ‘template<class _EuclideanRingElement> _EuclideanRingElement std::__gcd(_EuclideanRingElement, _EuclideanRingElement)’
 1199 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
/usr/include/c++/11/bits/stl_algo.h:1199:5: note:   template argument deduction/substitution failed:
answer.code:33:37: note:   deduced conflicting types for parameter ‘_EuclideanRingElement’ (‘long long int’ and ‘int’)
   33 |                 int o = c[u] / __gcd(f[u], c[u]);
      |                                ~~~~~^~~~~~~~~~~~