QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603011#9426. Relearn through Reviewkarito#Compile Error//C++17641b2024-10-01 14:07:182024-10-01 14:07:19

Judging History

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

  • [2024-10-01 14:07:19]
  • 评测
  • [2024-10-01 14:07:18]
  • 提交

answer

#include<iostream>
#include<vector>
using namespace std;
const int N = 3e5 + 10;
typedef long long ll;
ll dp[N][3];
ll gcd(ll x, ll y) {
	if (!y) return x;
	return gcd(y, x % y);
}
void solve() {
	int n;
	ll k;
	cin >> n >> k;
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	for (int i = 1; i <= n; i++) {
		ll x;
		cin >> x;
		dp[i][0] = gcd(dp[i - 1][0], x);
		dp[i][1] = max(gcd(dp[i - 1][1], x+k), gcd(dp[i - 1][0], x+k));
		dp[i][2] = max(gcd(dp[i - 1][1], x),gcd(dp[i-1][2],x));
	}
	cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
}
int main() {
	int T;
	cin >> T;
	while (T--) solve();
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:25:20: error: no matching function for call to ‘max(<brace-enclosed initializer list>)’
   25 |         cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:51,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:25:20: note:   candidate expects 2 arguments, 1 provided
   25 |         cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:25:20: note:   candidate expects 3 arguments, 1 provided
   25 |         cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~