【CodinGame】趣味算法 CLASH OF CODE - 20240723

在这里插入图片描述

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())
for i in range(n):
    name = input()
    # name里面的每个字符都是大写字母就输出VALID
    print('VALID' if all(c.isupper() for c in name) else 'INVALID')


注意:all()函数 - 这是一个内置函数,用于判断可迭代对象中的所有元素是否都为真。如果所有元素都为真,则返回True,否则返回False。



在这里插入图片描述

在这里插入图片描述

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())

count = 0
for i in range(n):
    fruits = input()
    if fruits == "logia":
        count+=100
    if fruits == "paramecia":
        count+=75
    if fruits == "zoan":
        count+=25
print(f"{count} beli")
        

更优雅的写法,用字典(作者:u_know_not)

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

n = int(input())
s=0
for i in range(n):
    fruits = input()
    s+={"logia":100,"paramecia":75,"zoan":25}[fruits]
print(s,"beli")



在这里插入图片描述

在这里插入图片描述


import sys
import math

is_leap = input()
year_type = input()
count = 0
count += 5*29+5*30
if is_leap == "LEAP":
    count+= 29
if year_type == "MISSING":
    count+=2*29
if year_type == "SERIAL":
    count+= 29+30
if year_type == "FULL":
    count+= 2*30
print(count)



在这里插入图片描述

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

m = int(input())
n = int(input())

# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)

# 相加和在1~7
print((m+n-1)%7+1)

这里可以理解(m+n)为窗口左右移动,后面的+1是为了窗口整体移动,让0 ~ 6变成1~7
或者这样也可以(作者:mmlyd)

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

m = int(input())
n = int(input())

# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
a = (m+n)%7
if a!=0:
    print(a)
else:
    print(7)

在这里插入图片描述



在这里插入图片描述
不完全

import sys
import math

# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.

months = input()

my_months = "JFMAMJJASOND"

# 检测到months在my_months的位置
print(my_months[(my_months.index(months)+len(months))%12])

END

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_千思_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值