QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#451364#6824. Demonstrational SequencesPetroTarnavskyiCompile Error//C++141.3kb2024-06-23 09:37:212024-06-23 09:37:22

Judging History

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

  • [2024-06-23 09:37:22]
  • 评测
  • [2024-06-23 09:37:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

//typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

ULL mod;

ULL mult(ULL a, ULL b)
{
	return a * b % mod;
}
ULL add(ULL a, ULL b)
{
	return a + b < mod ? a + b : a + b - mod;
}
ULL sub(ULL a, ULL b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}

const int N = 1 << 21;
int was[N];

ULL Q;

bool solve()
{
	fill(was, was + Q, -1);
	ULL a, b;
	cin >> a >> b;
	a %= mod;
	b %= mod;
	
	vector<ULL> vals;
	vals.reserve(Q);
	
	was[a % Q] = SZ(vals);
	vals.PB(a);

	while(true)
	{
		a = add(mult(a, a), b);
		
		if(was[a % Q] != -1)
		{
			ULL prev = vals[was[a % Q]];
			
			
			ULL d = (a > prev ? a - prev : prev - a);
			
			return gcd(d, mod) == Q;
		}
		was[a % Q] = SZ(vals);
		vals.PB(a);
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> mod >> Q >> t;
	
	while(t--)
		cout << solve();
	cout << "\n";
	
	return 0;
}

Details

answer.code: In function ‘bool solve()’:
answer.code:65:32: error: ‘gcd’ was not declared in this scope
   65 |                         return gcd(d, mod) == Q;
      |                                ^~~