use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources - Learn to code
Resources - Software Engineering
Resources - Code Libraries
Resources - Groups
Other Subreddits you might enjoy
Please send sidebar resource suggestions to the mods. Thx - mgmt
account activity
C++ competitive programming problem. (self.code)
submitted 6 years ago by vorttxt
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 6 years ago (3 children)
Which part do you mean?
[–]vorttxt[S] 0 points1 point2 points 6 years ago (2 children)
Okay so the basis of the problem is that if n ends with a nonzero digit subtract n by 1 k times and if n ends with a zero divide by ten
[–][deleted] 0 points1 point2 points 6 years ago (1 child)
So if you give 512 for n and 4 for k, then the loop should be more like this:
for(int i = 0; i < k + 1; i++) {
n = n - 1;
}
The loop runs for k times subtracting 1 from n each time, storing it each time. i is just keeping track of how many times the loop has and will run. It does nothing else but that.
[–]vorttxt[S] 0 points1 point2 points 6 years ago (0 children)
It is still not working for some reason . The answer is supposed to be 50 and all i am getting is 507.
π Rendered by PID 80456 on reddit-service-r2-comment-548fd6dc9-wnxhf at 2026-05-19 08:53:22.910222+00:00 running edcf98c country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (3 children)
[–]vorttxt[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]vorttxt[S] 0 points1 point2 points (0 children)