QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#386650#5108. Prehistoric ProgramsPetroTarnavskyi#WA 0ms3872kbC++201.1kb2024-04-11 19:05:262024-04-11 19:05:27

Judging History

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

  • [2024-04-11 19:05:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-04-11 19:05:26]
  • 提交

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 vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

LL m;
__int128 binpow(__int128 q, int n)
{
	__int128 res = 1;
	FOR(i, 0, n)
	{
		res *= q;
		if(res > m)
			return res;
	}
	return res;
}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	cin >> m;
	
	
	vector<__int128> qn;
	qn.PB(0);
	qn.PB(1);
	int Q = 2;
	while(true)
	{
		__int128 val = binpow(Q, n - 1);
		
		if(val > m)
			break;
		
		
		qn.PB(val * Q);
		Q++;
	}
	FOR(q, 2, SZ(qn))
	{
		RFOR(p, q, 1)
		{
			__int128 U = m;
			U *= (q - p);
			auto D = qn[q] - qn[p];
			
			if(U % D == 0)
			{
				cout << q - p << " " << q << "\n";
				return 0;
			}
		}
	}
	
	cout << "impossible\n";
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3872kb

input:

50000
(
(
))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()(
)
(
)
(((
(
(
(
(
(
()
(
)
(
)((())()((
)))))(
(
)
))
)()
(
)
)
)()(
(
(
()
(
)
(
)()((((())()))())(
(
(
)(
(
(
(()())())
)
)
(
(
(
)((())))((())))))))))((((()()))()))))))))((()())()))
)
)()
)
)
)
)
)
())(())))))()(()((()(())...

output:

impossible

result:

wrong answer you didn't find a solution but jury did