I decided to study for the programming test preparation for the entrance exam. Therefore, I will study because AtCoder was a site with many explanations in Japanese.
Study for programming test preparation
I thought that a site with many explanations would lead to my own study when taking a programming test. Therefore, when I was looking for a place where many programming tests were conducted in the Japanese community, I was studying because there was AtCoder.
a,b=map(int,input().split())
if a*b%2==0:
print('Even')
else :
print('Odd')
s=input()
count=0
for i in s:
# print(i)
if int(i)==1:
count+=1
# print(count)
print(count)
It's simple and I prefer this one. If I used count on 04/19, it failed with RunTimeError, so it is recommended to use the first answer.
python
print(input().count('1'))
###Alternative 2
How to guide your math skills
I don't really recommend it.
If you are good at math, you may like to write it.
print(int(input())%9)
##Question 3: [ABC 081 B - Shift Only](https://atcoder.jp/contests/abc081/tasks/abc081_b)
```python
N = int(input())
A = map(int, input().split())
count = 0
while all(a % 2 == 0 for a in A):
A = [a / 2 for a in A]
count += 1
print(count)
##Question 4: ABC 087 B - Coins
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
if X==500*a+100*b+50*c:
count+=1
print(count)
##Question 5: ABC 083 B - Some Sums I learned that using a map can be used for convenient sorting. I used it for the first time.
N = int(input())
A = int(input())
B = int(input())
N,A,B=map(int,input().split())
def FindSumOfDigits(num):
count = 0
while num > 0:
count += num % 10
# This is different / missing
num=num // 10
return count
for n in range(1, N+1):
count = FindSumOfDigits(n)
if A<= count <=B:
ans += n
print(ans)
##Question 6: ABC 088 B - Card Game for Two
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
Alice=Bob=0
for i in range(N):
if i%2==0:
Alice+=A[i]
else:
Bob+=A[i]
print(Alice-Bob)
##Question 7: ABC 085 B - Kagami Mochi
N=int(input())
d=[input() for _ in range(N)]
print(len(set(d)))
##Question 8: ABC 085 C - Otoshidama It was a problem that used mathematical skills such as solving simultaneous equations.
N, Y = map(int, input().split())
res10000 = res5000 = res1000 = -1
for a in range(N + 1):
for b in range(N + 1 - a):
c = N - a - b
if Y == 10000 * a + 5000 * b + 1000 * c:
res10000 = a
res5000 = b
res1000 = c
print(a, b, c)
##Question 9: ABC 049 C - Daydream
s = input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
# Rewriting if statement
print('NO' if s else 'YES')
if s:
print("NO")
else:
print("YES")
The idea of searching from behind and erasing
def main():
S = input()
while len(S) >= 5:
if len(S) >= 7 and S[-7:] == "dreamer":
S = S[:-7]
continue
if len(S) >= 6 and S[-6:] == "eraser":
S = S[:-6]
continue
elif S[-5:] == "dream" or S[-5:] == "erase":
S = S[:-5]
continue
else:
break
if len(S) == 0:
print("YES")
else:
print("NO")
main()
##Question 10: ABC 086 C - Traveling Mathematical solution
n=int(input())
for i in range(n):
t,x,y=map(int,input().split())
if (x+y) > t or (x+y+t)%2:
print('No')
exit()
print('Yes')
###Alternative 1 The royal way to solve
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
for i in range(N):
t[i+1], x[i+1], y[i+1] = map(int, input().split())
f = True
for i in range(N):
dt = t[i+1] - t[i]
dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
if dt < dist:
f = False
if dist%2 != dt%2:
f = False
print('Yes' if f else 'No')
###Betsukai 2
import sys
def main():
N = int(input())
t, x, y = 0, 0, 0
for _ in range(N):
next_t, next_x, next_y = [int(__) for __ in input().split()]
delta_t = next_t - t
distance = abs(next_x - x) + abs(next_y - y)
if distance > delta_t:
print("No")
sys.exit()
if (delta_t - distance) % 2 != 0:
print("No")
sys.exit()
t, x, y = next_t, next_x, next_y
print("Yes")
main()
#Impressions As for how to solve mathematics, I thought it would be a good idea for people who are not afraid to try to find the law by doing math firmly at school. Mathematically, I feel that I don't use it much because I feel that I have too much thought in competitive programming. #What I can do 1.I learned the basic idea of AtCoder 1.Ability to translate from esoteric problem sentences #Task 1.Try to solve a similar problem from the reference link 1.Challenge Leet Code #References
Recommended Posts