【CodinGame】CLASH OF CODE

声明:本文题目均来自CodinGame
在这里插入图片描述
在这里插入图片描述

import sys  
import math

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

n = int(input())

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

print(n+1)

抽屉原理,假设有N种颜色的袜子,那么在最坏的情况下是每种颜色的袜子我们都拿到一只,那么我们总共拿到了N只袜子,为了保证有两只相同颜色的,我们必须再抽一支,这样不管前面是什么颜色,新增的一只必定和之前抽出的某1种颜色相同



在这里插入图片描述


import sys  
import math

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

a = int(input())
b = int(input())

print((a + b)//2)

实际上就是等差数列然后找中间那个数,可以通过之和除以二来找



在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

import sys
import math

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

m = int(input())
for i in range(m):
    n = int(input())
    if n%2==0:
        print(n*2)
    else:
        print(n*3)





在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

import sys
import math

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

tone = input()
message = input()

# Helper function to check if a word contains fewer than 45% vowels
def has_fewer_than_45_percent_vowels(word):
    vowels = "aeiou"
    vowel_count = sum(1 for char in word if char in vowels)
    return vowel_count / len(word) < 0.45

# Step 1: Convert all words to lowercase
message = message.lower()

# Step 2: Remove all punctuation marks
punctuation = ",.?;!'"
for p in punctuation:
    message = message.replace(p, '')

# Step 3 and 4: Process each word
words = message.split()
processed_words = []

for word in words:
    if len(word) >= 5 and len(word) <= 8 and word[0].islower() and not word.endswith("ing") and has_fewer_than_45_percent_vowels(word):
        # Remove all vowels
        word = ''.join([char for char in word if char not in "aeiou"])
    processed_words.append(word)

# Step 5: Append a word to the end of the sentence based on the intended tone
if tone == "Funny":
    processed_words.append("lol")
elif tone == "Sad":
    processed_words.append(":(")
elif tone == "Happy":
    processed_words.append(":)")
elif tone == "Joyous":
    processed_words.append(":D")

# Output the result
print(" ".join(processed_words))

解释:
在这里插入图片描述

END

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

_千思_

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

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

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

打赏作者

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

抵扣说明:

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

余额充值