QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#4056. 进制转换

統計

小 D 两岁的时候就学会了进制转换。

所以他想问你,对于所有 $1 \sim n$ 之间的数,这个数在二进制和三进制下的数位和分别是多少。

对于 $i$,记二进制和三进制的数位和分别为 $a(i)$ 和 $b(i)$。比如对于一个数 $i=114$ ,那么它二进制表示为 $(1110010)_2$,三进制表示为 $(11020)_3$,那么 $a(i)$ 和 $b(i)$ 分别为 $4$ 和 $4$。

小 D 想知道你是不是真的能算对 $1$ 到 $n$ 里面所有数进制转换,所以想问你 $\sum_{i=1}^n x^iy^{a(i)}z^{b(i)}$ 是多少。由于答案很大,输出答案对 $998\,244\,353$ 取模的结果。

输入格式

一共一行,包含四个整数 $n,x,y,z$。

输出格式

输出一个数,表示答案。

样例数据

样例 1 输入

123456 12345 234567 3456789

样例 1 输出

664963464

样例 2 输入

1234567891 123 1 12345

样例 2 输出

517823355

样例 3 输入

9876543210987 1284916 83759265 128478129

样例 3 输出

115945104

子任务

一共 $20$ 个测试点。

对于测试点 $1, 2, 3$,$n \leq 10^7$。

对于测试点 $4, 5$,$x = y = 1$。

对于测试点 $6, 7$,$y = 1$。

对于测试点 $8, 9, 10$,$n \leq 10^{10}$。

对于测试点 $11, 12, 13, 14$,$n \leq 5\times 10^{11}$。

对于所有测试点,$1 \leq n \leq 10^{13}$,$1 \leq x,y,z < 998\,244\,353$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.