第一题 1A
题意:给一个n*m的矩形,和a*a的正方形。要用a*a的正方形去覆盖n*m的矩形,要求a*a的正方形不能切割开,但是两个a*a的正方形可以重叠,问最小需要几个这样的正方形
代码:
my_list = raw_input().split()
n = int(my_list[0])
m = int(my_list[1])
a = int(my_list[2])
print (n/a+(n%a>0))*(m/a+(m%a>0))
第二题 2A
题意:有很多人在玩纸牌游戏,总共玩n轮。每一轮里面包括玩家的名字,和玩家这一轮的得分,现在问最后谁的得分最高(假设为m),如果有多个人得分最高,输出最先得到m分的玩家
思路:我们先利用n轮求出最后每个人的得分这样就可以求出最大的分数m,然后枚举这么多个人去找如果得分为m的人就去从头模拟一遍找到得分为m分的轮数,最后找到赢家
代码:
# define some variable
n = int(raw_input())
maxScore = {}
input = []
# n times input
while n > 0:
list = raw_input().split()
input.append(list)
name = list[0]
score = int(list[1])
if maxScore.has_key(name):
maxScore[name] += score
else:
maxScore[name] = score
n -= 1
# find maxScore = ans
ans = 0
for key in maxScore:
ans = max(ans , maxScore[key])
# def to find the time >= ans
def getTime(str):
sum = 0
cnt = 0
for list in input:
name = list[0]
score = int(list[1])
if name == str:
sum += score
if sum >= ans:
return cnt
cnt += 1
# one by one if score == ans
time = 2147483647
for key in maxScore:
if maxScore[key] == ans:
t = getTime(key)
if time > t:
time = t
ansName = key
# output
print ansName
第三题 3A
题意:给定一个8*8的地图,再给定两个点s和t,s是起点,t为终点,问s到t最少需要几步,规定每一步可以往当前格子的8个方向移动,最后打印出路径
思路:由于每一个点可以往周围的8个方向移动,那么我们很快的求出最少需要的步数为ans = max(abs(s.x-t.x) , abs(s.y-t.y)),我们求出了最少需要的几步之后我们直接去模拟,只要满足走这一步能够减少距离那么就是符合的走法
代码:
# Class for Point
class Point:
def __init__(self , x , y):
self.x = x
self.y = y
# input start and end Point
str = raw_input()
start = Point(8-int(str[1]) , ord(str[0])-97)
str = raw_input()
end = Point(8-int(str[1]) , ord(str[0])-97)
# solve this problem
dir = [[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1]]
move = ["U","RU","R","RD","D","LD","L","LU"]
ans = max(abs(start.x-end.x) , abs(start.y-end.y))
# output
print ans
m = ans
x = start.x
y = start.y
# print "%d %d" % (start.x , start.y)
# print "%d %d" % (end.x , end.y)
while m > 0:
for i in range(8):
tmpx = x+dir[i][0]
tmpy = y+dir[i][1]
if (tmpx >= 0 and tmpx < 8 and tmpy >= 0 and tmpy < 8):
dis = max(abs(tmpx-end.x) , abs(tmpy-end.y))
if dis < m:
print move[i]
x = tmpx
y = tmpy
break
m -= 1
分享到:
相关推荐
在python和bash中使用简单的解析和检查实现,以解决Codeforce中的竞赛。\ 安装 git clone " https://github.com/siddharth17196/codeforces-cli.git " cd codeforces-cli/scripts bash install.sh 将以下内容添加...
Codeforces-Round-492-:解决问题shorturl.atetAIW
codeforces-scraper:刮除来自codeforces的解决方案
:exploding_head: :exploding_head: :female_sign: 我准备链接问题和解决方案 :person_raising_hand: :female_sign: 您已克隆并尝试以下操作:使用Python代码,必须先下载python然后再运行它 :star: :female_sign: ...
codeforces-crawler 一个建议问题,进行虚拟竞赛并为编码平台codeforce的用户显示用户统计信息的网站。 网站链接: 要求 安装要求 导航到目录并运行 点安装-r requirements.txt 运行项目 导航到目录并运行 python ...
CodeForces 适用于问题的Python解决方案。 用户名: hopper19
Codeforces解决方案
单击问题名称以访问Codeforces上的原始问题页面,进行解决,然后返回此处并重复。 祝你好运,高评价! 链接到已部署的应用程序 链接到Codeforces博客 注意 随时提出有关错误/改进的问题。 如果对存储库有任何帮助...
Codeforces解决方案该存储库包含我在codeforces.com上提交并接受的各种问题的解决方案。
Python竞争性编程解决方案 此仓库由My Python解决方案组成,用于解决LeetCode,HackerEarth,GeeksforGeeks,Codechef等各种问题。 解决方案将定期更新。
Codeforces问题解决方案
codeforces解决方案个人资料链接
Codeforces - 比赛于凌晨 12.30 开始 635 Div 2 (16-04-2020) - 排名 11707/21686 参与者 637 Div 2 (24-04-2020) - 排名 12511/23207 参与者 638 Div 2 (02-05-2020) - 排名 9926/24059 参与者 639 Div 2 未评级 ...
Codeforces_Problemset_Solution Codeforces问题的解决方案将在这里上传。 我将尝试使用C ++解决大多数问题。
cp工具 cp-tool是一个自动生成器,用于解决不同在线法官的问题。 它收集了在线法官解决的所有问题,并为... cp-tool -c init -j codeforces 您会被要求 处理 例如: shifat57 存储库名称(将根据存储库名称创建一个文
如果解决方案已经存在,则将不会合并。 遵循命名约定。 例如:107D。 问题的名称.cpp 我在编码时经常忘记的事情: 使用lambda在python3中排序: 假设x是一个元组,并且排序将取决于x [0],如果x [0]相等,则x [1]...
力编码器 无需打开网站即可解决 CodeForces Round 问题! 文档和使用方法即将推出
跟踪您的竞争对手一个命令行实用程序,可以在Spoj,Codechef,Codeforces等各种在线法官上跟踪您的竞争对手。 想要查看您在Codechef上的朋友状态,或想要解决竞争对手在SPOJ上遇到的所有问题。 尝试跟踪您的竞争对手...
这种工具可以自动从codeforces找到高质量的Python解决的任务。 我写这个工具是为了帮助我找到好的资源来提高我的 Python 技能。 cd codeforces python solution-finder.py (number of the contest, e.g. 988) ...
解决 CodeForces 问题