QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#269411#7881. Computational Complexityucup-team1453#WA 19ms13044kbC++111.7kb2023-11-29 16:46:422023-11-29 16:46:43

Judging History

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

  • [2023-11-29 16:46:43]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:13044kb
  • [2023-11-29 16:46:42]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define vi vector <int>
#define sz(a) ((int) (a).size())
#define me(f, x) memset(f, x, sizeof(f))
#define uint unsigned int
#define ull unsigned long long 
#define i128 __int128
using namespace std; 
const int N = 1e6 + 7;
const ll mxm = 1e15;
ll mod;
int q; 
ll f[N], g[N];
int df[4] = {2, 3, 5, 7};
int dg[4] = {2, 3, 4, 5};
ll arr[N];
int tot;
unordered_map < ll, int > mp;
unordered_set < ll > st;
void dfs(ll x) {
	if(x > mxm)return;
	if(st.count(x))return;
	arr[++tot] = x;
	st.insert(x);
	dfs(x * 2);
	dfs(x * 3);
	dfs(x * 5);
	dfs(x * 7);
}
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> f[0] >> g[0] >> q >> mod;
	L(i, 1, 11) {
		f[i] = max((ll)i, g[i / 2] + g[i / 3] + g[i / 5] + g[i / 7]);
		g[i] = max((ll)i, f[i / 2] + f[i / 3] + f[i / 4] + f[i / 5]);
	}
	L(i, 0, 11) f[i] %= mod;
	L(i, 1, 12) dfs(i);
	R(i, 11, 0) {
		f[i + 1] -= f[i]; 
		g[i + 1] -= g[i];
	}
	L(i, 1, 12) {
		f[i] = (f[i] % mod + mod) % mod;
		g[i] = (g[i] % mod + mod) % mod;
	}
	sort(arr + 1, arr + tot + 1);
	L(i, 1, tot) mp[arr[i]] = i;
	L(i, 0, tot) {
		L(j, 0, 3) {
			ll go = arr[i] * dg[j];
			go = max(go, 12LL);
			if(go <= mxm) {
				(g[mp[go]] += f[i]) %= mod;
			}
		}
		
		L(j, 0, 3) {
			ll go = arr[i] * df[j];
			go = max(go, 12LL);
			if(go <= mxm) {
				(f[mp[go]] += g[i]) %= mod;
			}
		}
	}
	L(i, 1, tot) {
		(f[i] += f[i - 1]) %= mod;
		(g[i] += g[i - 1]) %= mod;
	}
	
	while(q--) {
		ll m;
		cin >> m;
		int pos = upper_bound(arr + 1, arr + tot + 1, m) - arr - 1;
		cout << f[pos] << " " << g[pos] << '\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 12804kb

input:

1958 920 10 100000000000
0
1
2
3
10
100
200
1000
19580920
20232023

output:

1958 920
3680 7832
10592 9554
17504 11276
50294 64826
784112 893714
1894550 1905470
12057866 12979424
71481494756 48626708512
28127864908 7251681354

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 19ms
memory: 13044kb

input:

0 0 10 100000000000
0
1
2
3
4
10
20
30
40
100

output:

0 0
1 1
2 2
3 3
4 4
11 12
25 26
41 41
55 58
162 172

result:

ok 20 numbers

Test #3:

score: -100
Wrong Answer
time: 14ms
memory: 12724kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

0 2023
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

result:

wrong answer 2nd numbers differ - expected: '0', found: '2023'