QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#466806#4783. 神秘货币5ab22 1ms4104kbC++201.8kb2024-07-08 10:17:462024-07-08 10:17:46

Judging History

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

  • [2024-07-08 10:17:46]
  • 评测
  • 测评结果:22
  • 用时:1ms
  • 内存:4104kb
  • [2024-07-08 10:17:46]
  • 提交

answer

#include "currency.h"
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;

const int N = 1e3;
const ll L = 1e18;

bool isp[N + 1];
int ans[N];

void solve(int type)
{
assert(type == 2);
	vector<int> p;
	for (int i = 2; i <= N; i++)
		if (!isp[i])
		{
			for (int j = i * 2; j <= N; j += i)
				isp[j] = 1;
			p.push_back(i);
		}
	
	auto mx = [&](int x, int el = 1)
	{
		int c = 1, d = 0;
		while (c * x * el <= N)
			c *= x, d++;
		return make_pair(c, d);
	};
	
	vector<pair<int, ll>> cs;
	
	int ci = 0;
	while (ci < ssz(p))
	{
		int cj = 0, cd = 0;
		ll cv = 1;
		while (cj < ci && p[cj] * p[ci] <= N)
		{
			auto [c, d] = mx(p[cj], p[ci]);
			if (L / cv < c)
				break;
			cv *= c, cj++;
			cd += (d <= 1 ? d : __lg(d - 1) + 1);
			// cerr << cv << " " << c << endl;
		}
		while (ci < ssz(p))
		{
			auto [c, d] = mx(p[ci]);
			if (L / cv < c)
				break;
			cv *= c, ci++;
			cd += (d <= 1 ? d : __lg(d - 1) + 1);
		}
		cs.emplace_back(cd, cv);
	}
	sort(all(cs), greater());
	for (auto [_, x] : cs)
		if (query(x))
		{
			// cerr << x << " start" << endl;
			for (int i = 2; i <= N; i++)
				if (!isp[i] && x % i == 0)
				{
					int l = 0, r = 0; ll y = x;
					for ( ; y % i == 0; r++, y /= i);
					while (l < r)
					{
						int mid = (l + r) >> 1;
						ll z = y;
						for (int j = 0; j < mid; j++)
							z *= i;
						if (query(z))
							r = mid;
						else
							l = mid + 1;
					}
					// cerr << l << " " << r << endl;
					for (int j = 0; j < l; j++)
						y *= i;
					x = y;
				}
			ans[0] = x;
			answer(1, ans);
			break;
		}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

1

output:


result:


Subtask #2:

score: 22
Accepted

Test #6:

score: 22
Accepted
time: 0ms
memory: 3840kb

input:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 99585663281
Q 7660435637
Q 450613861
Q 23716519
Q 1031153
Q 35557
Q 1147
Q 37
Q 1
A 1
1

result:

ok Correct!

Test #7:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

2
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 697099642967
Q 53623049459
Q 41005861351
Q 2158203229
Q 93834923
Q 3235687
Q 104377
Q 3367
Q 91
A 1
91

result:

ok Correct!

Test #8:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

2
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 82815437584479600
Q 41407718792239800
Q 9201715287164400
Q 3067238429054800
Q 613447685810960
Q 122689537162192
Q 17527076737456
Q 1593370612496
Q 122566970192
Q 7209821776
Q 379464304
Q 16498448
Q 568912
Q 532208
Q 17168
Q 464
A 1
464

result:

ok Correct!

Test #9:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

2
1
1
1
0
1
1
1
1
1
0
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 1150214410895550
Q 383404803631850
Q 76680960726370
Q 15336192145274
Q 2190884592182
Q 199171326562
Q 168529584014
Q 9913504942
Q 521763418
Q 22685366
Q 782254
Q 731786
Q 23606
Q 638
A 1
638

result:

ok Correct!

Test #10:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 99585663281
Q 7660435637
Q 450613861
Q 23716519
Q 1031153
Q 817811
Q 765049
Q 24679
Q 667
A 1
667

result:

ok Correct!

Test #11:

score: 0
Accepted
time: 0ms
memory: 4100kb

input:

2
0
0
0
0
0
1
1
1
0
1
1
1
1
1
1
1
0
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 5527330634957670
Q 2763665317478835
Q 921221772492945
Q 552733063495767
Q 78961866213681
Q 7178351473971
Q 86486162337
Q 971754633
Q 10018089
Q 99189
Q 963
Q 927
A 1
927

result:

ok Correct!

Test #12:

score: 0
Accepted
time: 0ms
memory: 3868kb

input:

2
1
0
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 82815437584479600
Q 18403430574328800
Q 6134476858109600
Q 1226895371621920
Q 245379074324384
Q 35054153474912
Q 3186741224992
Q 245133940384
Q 14419643552
Q 758928608
Q 32996896
Q 1137824
Q 1064416
Q 34336
Q 928
A 1
928

result:

ok Correct!

Test #13:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 99585663281
Q 7660435637
Q 450613861
Q 23716519
Q 1031153
Q 35557
Q 1147
Q 961
A 1
961

result:

ok Correct!

Test #14:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

2
0
1
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 14777180087670000
Q 3694295021917500
Q 1847147510958750
Q 136825741552500
Q 1231431673972500
Q 410477224657500
Q 49257266958900
Q 9851453391780
Q 1970290678356
Q 40210013844
Q 5744287692
Q 522207972
Q 47473452
Q 3651804
Q 280908
Q 16524
Q 972
A 1
972

result:

ok Correct!

Test #15:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
0
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 5878452059740260
Q 2939226029870130
Q 1469613014935065
Q 489871004978355
Q 163290334992785
Q 32658066998557
Q 4665438142651
Q 424130740241
Q 32625441557
Q 1919143621
Q 101007559
Q 4391633
Q 2463599
Q 57293
Q 52417
Q 989
A 1
989

result:

ok Correct!

Test #16:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

2
0
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 14777180087670000
Q 3694295021917500
Q 7388590043835000
Q 273651483105000
Q 30405720345000
Q 10135240115000
Q 405409604600
Q 2027048023000
Q 41368327000
Q 5909761000
Q 537251000
Q 48841000
Q 3757000
Q 289000
Q 17000
Q 1000
A 1
1000

result:

ok Correct!

Test #17:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 1150214410895550
Q 383404803631850
Q 76680960726370
Q 15336192145274
Q 2190884592182
Q 199171326562
Q 15320871274
Q 901227722
Q 47433038
Q 2062306
Q 71114
Q 2294
Q 74
Q 2
A 1
2

result:

ok Correct!

Test #18:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

2
1
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 82815437584479600
Q 18403430574328800
Q 55210291722986400
Q 33126175033791840
Q 6625235006758368
Q 946462143822624
Q 86042013074784
Q 6618616390368
Q 389330375904
Q 20491072416
Q 890916192
Q 30721248
Q 991008
Q 31968
Q 864
A 1
864

result:

ok Correct!

Test #19:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

2
1
1
0
1
1
1
0
1
1
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 2300428821791100
Q 766809607263700
Q 153361921452740
Q 30672384290548
Q 21908845921820
Q 1991713265620
Q 153208712740
Q 9012277220
Q 474330380
Q 20623060
Q 711140
Q 665260
Q 21460
Q 580
A 1
580

result:

ok Correct!

Test #20:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 19594168891719614
Q 1280440868936...

result:

ok Correct!

Test #21:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
1
1
1
1
0
1
1
1
0
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 1725321616343325
Q 345064323268665
Q 69012864653733
Q 9858980664819
Q 6273896786703
Q 482607445131
Q 28388673243
Q 1494140697
Q 64962639
Q 2240091
Q 72261
Q 2331
Q 63
A 1
63

result:

ok Correct!

Test #22:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

2
0
0
0
0
1
1
1
1
1
0
0
1
1
1
1
0
1
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 17789819107640580
Q 8894909553820290
Q 4447454776910145
Q 1482484925636715
Q 494161641878905
Q 296496985127343
Q 211783560805245
Q 19253050982295
Q 1481003921715
Q 25101761385
Q 411504285
Q 37465...

result:

ok Correct!

Test #23:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 19594168891719614
Q 1280440868936...

result:

ok Correct!

Test #24:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 19594168891719614
Q 1280440868936...

result:

ok Correct!

Test #25:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

2
0
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 14777180087670000
Q 3694295021917500
Q 1847147510958750
Q 923573755479375
Q 34206435388125
Q 307857918493125
Q 102619306164375
Q 4104772246575
Q 820954449315
Q 164190889863
Q 16754172435
Q 2393453205
Q 217586655
Q 19780605
Q 1521585
Q 117045
Q 6885
Q 405
A...

result:

ok Correct!

Test #26:

score: 0
Accepted
time: 1ms
memory: 4064kb

input:

2
1
1
1
0
1
0
1
1
1
0
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 1150214410895550
Q 383404803631850
Q 230042882179110
Q 46008576435822
Q 6572653776546
Q 597513979686
Q 505588752042
Q 29740514826
Q 1565290254
Q 68056098
Q 2346762
Q 75702
Q 2442
Q 66
A 1
66

result:

ok Correct!

Test #27:

score: 0
Accepted
time: 1ms
memory: 4088kb

input:

2
1
1
1
0
0
1
1
1
1
0
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 1150214410895550
Q 3450643232686650
Q 690128646537330
Q 138025729307466
Q 19717961329638
Q 1792541939058
Q 1516766256126
Q 89221544478
Q 4695870762
Q 204168294
Q 7040286
Q 227106
Q 7326
Q 198
A 1
198

result:

ok Correct!

Test #28:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

2
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 115021441089555
Q 23004288217911
Q 3286326888273
Q 298756989843
Q 22981306911
Q 1351841583
Q 71149557
Q 3093459
Q 106671
Q 3441
Q 111
Q 3
A 1
3

result:

ok Correct!

Test #29:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

2
1
1
1
1
1
0
1
1
0
1
1
0
1
1
1
1
1
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 115021441089555
Q 23004288217911
Q 3286326888273
Q 2091298928901
Q 160869148377
Q 9462891081
Q 8466797283
Q 368121621
Q 12693849
Q 409479
Q 13209
Q 357
A 1
357

result:

ok Correct!

Test #30:

score: 0
Accepted
time: 1ms
memory: 3804kb

input:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 99585663281
Q 7660435637
Q 450613861
Q 23716519
Q 1031153
Q 35557
Q 1147
Q 37
Q 31
A 1
31

result:

ok Correct!

Test #31:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0

output:

Q 165630875168959200
Q 20703859396119900
Q 10351929698059950
Q 5175964849029975
Q 575107205447775
Q 191702401815925
Q 38340480363185
Q 7668096072637
Q 1095442296091
Q 99585663281
Q 7660435637
Q 450613861
Q 23716519
Q 1031153
Q 35557
Q 1147
Q 37
Q 1
A 1
37

result:

ok Correct!

Test #32:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

2
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 5527330634957670
Q 2763665317478835
Q 921221772492945
Q 307073924164315
Q 61414784832863
Q 8773540690409
Q 797594608219
Q 9609573593
Q 107972737
Q 1113121
Q 11021
Q 107
Q 103
...

result:

ok Correct!

Test #33:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 15916020492768661
Q 3268176692560...

result:

ok Correct!

Test #34:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
1
1

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 15916020492768661
Q 3268176692560...

result:

ok Correct!

Test #35:

score: 0
Accepted
time: 1ms
memory: 4104kb

input:

2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0

output:

Q 165630875168959200
Q 472869762805440000
Q 23513808238961040
Q 413231728411101600
Q 71159276430562320
Q 22109322539830680
Q 9833675347306440
Q 738460249059364620
Q 178655885634150060
Q 742452569487280266
Q 540032994667500324
Q 6340324843176594
Q 31832040985537322
Q 19594168891719614
Q 1280440868936...

result:

ok Correct!

Subtask #3:

score: 0
Runtime Error

Test #36:

score: 0
Runtime Error

input:

3

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #56:

score: 0
Runtime Error

input:

4

output:


result:


Subtask #5:

score: 0
Runtime Error

Test #71:

score: 0
Runtime Error

input:

5

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #86:

score: 0
Runtime Error

input:

6

output:


result: