Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14行第二个条件判断是多余的 #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

14行第二个条件判断是多余的 #16

wants to merge 1 commit into from

Conversation

youkaichao
Copy link

ans[m] != 0就说明已经被小的生成元填充过了。

@@ -11,7 +11,7 @@ int main() {
for(int m = 1; m < maxn; m++) {
int x = m, y = m;
while(x > 0) { y += x % 10; x /= 10; }
if(ans[y] == 0 || m < ans[y]) ans[y] = m;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但还是需要判断y < maxn,不然y会溢出ans[maxn]
if(ans[y] == 0 && y < maxn) ans[y] = m;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants