I won't explain my codes. I just post it to help you, when you are testing your code. Here you can see the tasks.

# Moon

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 #include #include using namespace std; vector > table; vector bin; int extend(int y, int x, int r); int power(int a){return a*a;} int w,h; int main() { cin >> w >> h; bin.resize(w,0); table.resize(h,bin); char input_helper; int x=0,y=0,r=-1; for(int a=0;a> input_helper; table[a][b]=(input_helper=='.')?0:1; } int center[h][w]; for(int a=0;acenter[a][b])?r:center[a][b]; } } } for(y=0;y=w||y-r<0||y+r>=h) return 0; for(int a=x-r;a<=x+r;a++){ for(int b=y+r;b>=y-r;b--){ if(table[b][a]==1) continue; if(power(a-x)+power(b-y)<=power(r)) return 0; } } return 1+extend(y,x,r+1); } 

# Factorisation

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #include #include using namespace std; typedef long long int longint; vector first; vector second; vector solution; const longint minimum=2; longint maximum=1000000; int main() { first.resize(maximum+1,0); second.resize(maximum+1,0); for(int a=minimum;a<=maximum;a++){ if(second[a]==-1) continue; for(int b=a;b<=maximum;b+=a){ first[b]++; second[b]=(second[b]==-1)?-1:(second[b]==0)?a:(a%second[b]==0)?second[b]:-1; } } for(int a=minimum;a<=maximum;a++){ if(first[a]>=solution.size()) solution.resize(first[a]+1,0); solution[first[a]]++; } for(int a=1;a

Note by Páll Márton
1 week, 1 day ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$