QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84370#1875. NeinzhaohaikunWA 133ms3476kbC++142.3kb2023-03-06 12:54:292023-03-06 12:54:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 12:54:32]
  • 评测
  • 测评结果:WA
  • 用时:133ms
  • 内存:3476kb
  • [2023-03-06 12:54:29]
  • 提交

answer

#include <bits/stdc++.h>
#define int __int128
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) { putchar('-'); x *= -1; }
	if (x > 9) write(x / 10);
	putchar(x % 10 + 48);
}
template <typename T> void writes(T x) { write(x); putchar(32); }
template <typename T> void writeln(T x) { write(x); puts(""); }
const int N = 45;
int k, n, pw[N], a[N], s[N], t[N], f[N][N], g[N][N];
int calc(int pos) {
	ms(s, 0); ms(t, 0);
	F(i, pos + 1, 37) t[i % k] += a[i];
	F(i, 0, pos) s[i % k]++;
	int sum = 0;
	F(i, 1, 20) {
		// i = 1;
		int ans = i * (pw[k] - 1);
		// writeln(ans);
		ms(f, 0);
		f[0][0] = 1;
		F(j, 0, k - 1) {
			// writes(ans % 10); writes(t[j]), writeln(s[j]);
			F(tt, 0, 20)
				F(l, 0, s[j] * 8)
					if ((tt + l + t[j]) % 10 == ans % 10) {
						// if (tt == 0 && l == 8) {
						// 	writes(f[j][tt]), writeln(g[s[j]][l]);
						// 	cout << " -> ", writeln((tt + l + t[j]) / 10);
						// }
						f[j + 1][(tt + l + t[j]) / 10] += f[j][tt] * g[s[j]][l];//, writes(s[j]), writes(l), writeln(g[s[j]][l]);
					}
			ans /= 10;
		}
		// writeln(ans);
		// puts("!!!");
		// writeln(f[k][ans]);
		// exit(0);
		sum += f[k][ans];
		if (sum > n) return n;
	} return sum;
}
signed main() {
	read(k); read(n);
	pw[0] = 1;
	F(i, 1, 37) pw[i] = pw[i - 1] * 10;
	g[0][0] = 1;
	F(i, 1, 37)
		F(j, 0, (i - 1) * 8)
			F(k, 0, 8)
				g[i][j + k] += g[i - 1][j];
	// writeln(g[2][5]);
	// a[1] = 1;
	// writeln(calc(0));
	// return 0;
	DF(i, 37, 0) {
		F(j, 0, 8) {
			a[i] = j;
			int s = calc(i - 1);
			if (s < n) n -= s;
			else break;
		}
	} int sum = 0;
	F(i, 0, 37) sum += pw[i] * a[i];
	write(sum / (pw[k] - 1));
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 3348kb

input:

1 1

output:

2

result:

ok answer is '2'

Test #2:

score: 0
Accepted
time: 4ms
memory: 3332kb

input:

1 8

output:

9

result:

ok answer is '9'

Test #3:

score: 0
Accepted
time: 4ms
memory: 3372kb

input:

1 9

output:

12

result:

ok answer is '12'

Test #4:

score: 0
Accepted
time: 3ms
memory: 3332kb

input:

1 10

output:

13

result:

ok answer is '13'

Test #5:

score: 0
Accepted
time: 9ms
memory: 3416kb

input:

5 1

output:

11112

result:

ok answer is '11112'

Test #6:

score: 0
Accepted
time: 10ms
memory: 3340kb

input:

5 84

output:

11235

result:

ok answer is '11235'

Test #7:

score: 0
Accepted
time: 7ms
memory: 3368kb

input:

5 668

output:

12345

result:

ok answer is '12345'

Test #8:

score: 0
Accepted
time: 13ms
memory: 3420kb

input:

5 733942

output:

2281488

result:

ok answer is '2281488'

Test #9:

score: 0
Accepted
time: 115ms
memory: 3316kb

input:

18 528599760553218747

output:

30725517742188427234

result:

ok answer is '30725517742188427234'

Test #10:

score: 0
Accepted
time: 133ms
memory: 3456kb

input:

18 964828716126767591

output:

55758681752658348563

result:

ok answer is '55758681752658348563'

Test #11:

score: 0
Accepted
time: 115ms
memory: 3384kb

input:

18 401057671700316435

output:

22687686284122211545

result:

ok answer is '22687686284122211545'

Test #12:

score: 0
Accepted
time: 121ms
memory: 3348kb

input:

18 837286627273865280

output:

48255733668453323265

result:

ok answer is '48255733668453323265'

Test #13:

score: 0
Accepted
time: 116ms
memory: 3332kb

input:

18 273515582847414124

output:

15116382182883344554

result:

ok answer is '15116382182883344554'

Test #14:

score: 0
Accepted
time: 122ms
memory: 3476kb

input:

18 55923968082999579

output:

2876461768512185545

result:

ok answer is '2876461768512185545'

Test #15:

score: 0
Accepted
time: 47ms
memory: 3416kb

input:

8 715524960511324231

output:

12022650248772112989

result:

ok answer is '12022650248772112989'

Test #16:

score: 0
Accepted
time: 99ms
memory: 3412kb

input:

16 151753916084873076

output:

6182363727541142425

result:

ok answer is '6182363727541142425'

Test #17:

score: -100
Wrong Answer
time: 60ms
memory: 3348kb

input:

2 587982875953389216

output:

695847362514029180

result:

wrong answer expected '4754915500630529532', found '695847362514029180'