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


python 复制代码
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):
    t, c = [int(j) for j in input().split()]
    if c>14 or t<=0 or t>101:
        print("GLaDOS you filthy liar!")
    else:
        print("That's a cake!")




# print("That's a cake! or GLaDOS you filthy liar!")


python 复制代码
import sys
import math

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

x, y = [int(i) for i in input().split()]
n = int(input())
for i in range(n):
    inputs = input().split()
    _dir = inputs[0]
    dist = int(inputs[1])
    if _dir == 'N':
        y += dist
    elif _dir == 'S':
        y -= dist
    elif _dir == 'E':
        x += dist
    elif _dir == 'W':
        x -= dist

print(x,y)



python 复制代码
import sys
import math
from math import log2

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

n = int(input())

if log2(n) == int(log2(n)):
    print(int(log2(n)))
else:
    print(-1)


python 复制代码
import sys
import math

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

problem = input()



if eval(problem.replace('?', '+').replace('=', '==')):
    print("+")
if eval(problem.replace('?', '-').replace('=', '==')):
    print("-")
if eval(problem.replace('?', '*').replace('=', '==')):
    print("*")
if eval(problem.replace('?', '/').replace('=', '==')):
    print("/")

eval不安全,看情况使用

END

相关推荐
Cathy Bryant几秒前
傅里叶变换(二):旋转楼梯
笔记·算法·数学建模·信息与通信·傅里叶分析
2401_841495642 分钟前
【LeetCode刷题】零钱兑换
数据结构·python·算法·leetcode·动态规划·数组·时间复杂度
山海青风3 分钟前
人工智能基础与应用 - 数据处理、建模与预测流程 2 : 数据与问题类型
人工智能·python
C雨后彩虹5 分钟前
ConcurrentHashMap 源码逐行拆解:put/get 方法的并发安全执行流程
java·算法·哈希算法·集合·hashmap
无限进步_7 分钟前
C++ STL list容器深度解析与模拟实现
开发语言·数据结构·c++·windows·git·list·visual studio
子夜江寒8 分钟前
SVM、K-means与DBSCAN 算法简介
算法·支持向量机·kmeans
moshuying8 分钟前
RAG技术演进:从外部知识库到智能体核心记忆系统
python
IT·小灰灰1 小时前
探索即梦生图AI与AI Ping平台的创新融合:技术实践与代码实现
人工智能·python
deephub1 小时前
CALM自编码器:用连续向量替代离散token,生成效率提升4倍
人工智能·python·大语言模型
94621931zyn63 小时前
关于应用 - Cordova 与 OpenHarmony 混合开发实战
笔记·python