Solved AtCoder ABC 114 C-755 with Python3

I tried to solve AtCoder's 755 C problem in Python. This is an easy problem to solve using a recursive function.

I referred to an article by Mr. Kencho, who is well known in the Japanese competitive programming world. Reference article: https://drken1215.hatenablog.com/entry/2019/04/03/125400

It's still awkward, so I had a hard time understanding the difference between logical and bitwise operators. Click here for articles that helped me understand these ↓ http://ings.sakura.ne.jp/prog/bitoperator.html

N = int(input())

def func(cur, use, counter):
  if cur > N: return
  if use == 0b111: counter.append(1)  #Increase the answer
    
  #Add 7
  func(cur * 10 + 7, use | 0b001, counter)
  #Add 5
  func(cur * 10 + 5, use | 0b010, counter)
  #Add 3
  func(cur * 10 + 3, use | 0b100, counter)
  
res = []
func(0, 0, res)
print(sum(res))

The result looks like this. I was able to AC safely. Screen Shot 2020-05-10 at 13.42.52.png

Recommended Posts

Solved AtCoder ABC 114 C-755 with Python3
Solve AtCoder ABC166 with python
ABC188 C problem with python3
Solve AtCoder ABC 186 with Python
ABC187 C problem with python
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
Solve ABC163 A ~ C with Python
AtCoder ABC187 Python
AtCoder ABC188 Python
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
Solve ABC158 A ~ C with Python
AtCoder ABC 175 Python
[AtCoder explanation] Control ABC180 A, B, C problems with Python!
[AtCoder explanation] Control ABC188 A, B, C problems with Python!
[AtCoder explanation] Control ABC158 A, B, C problems with Python!
Solving with Ruby and Python AtCoder ABC011 C Dynamic programming
[AtCoder explanation] Control ABC164 A, B, C problems with Python!
[AtCoder explanation] Control ABC168 A, B, C problems with Python!
[AtCoder] Solve ABC1 ~ 100 A problem with Python
Solve AtCoder ABC168 with python (A ~ D)
Solve AtCoder 167 with python
ABC147 C --HonestOrUnkind2 [Python]
[AtCoder commentary] Win the ABC165 C problem "Many Requirements" with Python!
Solving with Ruby, Perl, Java, and Python AtCoder ABC 065 C factorial
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
Solving with Ruby AtCoder ABC110 C String Manipulation
[AtCoder explanation] Control the A, B, C problems of ABC182 with Python!
AtCoder ABC172 C Cumulative Sum Binary Search Solved by Ruby and Python
Solve with Ruby, Perl, Java and Python AtCoder ABC 047 C Regular Expression
[AtCoder explanation] Control the A, B, C problems of ABC187 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC184 with Python!
AtCoder ABC 177 Python (A ~ E)
Light blue with AtCoder @Python
AtCoder ABC 178 Python (A ~ E)
Atcoder ABC164 A-C in Python
ABC memorandum [ABC163 C --managementr] (Python)
AtCoder ABC 176 Python (A ~ E)
Atcoder ABC167 A-D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
AtCoder ABC 182 Python (A ~ D)
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Solve Atcoder ABC176 (A, B, C, E) in Python
[AtCoder explanation] Control the A, B, (C), D problems of ABC165 with Python!
[AtCoder explanation] Control the A, B, C, D problems of ABC181 with Python!
ABC memorandum [ABC159 C --Maximum Volume] (Python)
Call C from Python with DragonFFI
Create Awaitable with Python / C API
Solving with Ruby and Python AtCoder ABC178 D Dynamic programming
ABC127 A, B, C Explanation (python)
Solving with Ruby and Python AtCoder ABC151 D Breadth-first search
atCoder 173 Python
Solve ABC166 A ~ D with Python
Solve with Ruby and Python AtCoder ABC133 D Cumulative sum
ABC166 in Python A ~ C problem
Solve Atcoder ABC169 A-D in Python
Atcoder ABC125 C --GCD on Blackboard
ABC memorandum [ABC161 C --Replacing Integer] (Python)