QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#238393#7688. Alea Iacta Estucup-team191#TL 0ms3588kbC++14912b2023-11-04 16:35:522023-11-04 16:35:52

Judging History

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

  • [2023-11-04 16:35:52]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3588kb
  • [2023-11-04 16:35:52]
  • 提交

answer

#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 2e6 + 500;

int tmp[N], odg[N], cnt[N];

void solve(){
	int n, m; scanf("%d%d", &n, &m);
	if(n < m) swap(n, m);
	ll fak = n * m;
	int f1 = -1, f2;
	for(ll i = 1;i * i <= fak;i++) {
		if(fak % i == 0 && i != m) f1 = i;
	}
	if(f1 == -1) {
		printf("0\n0\n");
		return;
	}
	f2 = fak / f1;
	for(int i = 2;i <= n + m;i++)
		cnt[i] = min(i - 1, n) - max(i - m, 1) + 1;
	printf("%d ", f1);
	for(int i = 0;i < f1;i++) printf("%d ", i + 1);
	printf("\n%d ", f2);
	int cur = 0, sad = 1;
	for(int i = 0;i < f2;i++) {
		while(cur == cnt[sad]) {
			sad++; cur -= tmp[sad];
		}
		printf("%d ", sad - 1);
		cur++; tmp[sad + f1]++;
	}
	printf("\n");
	for(int i = 0;i <= n + m + 100;i++) tmp[i] = 0, odg[i] = 0, cnt[i] = 0;
}

int main(){
	int T; scanf("%d", &T);
	for(;T--;) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

3
2 8
1 9
2 9

output:

4 1 2 3 4 
4 1 2 5 6 
3 1 2 3 
3 1 4 7 
3 1 2 3 
6 1 2 4 5 7 8 

result:

ok Correct. (3 test cases)

Test #2:

score: -100
Time Limit Exceeded

input:

1
40013 40013

output:

1 1 
1601040169 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 14 14 14 14 14 14 14 14 14 15 15 15 15 15...

result: