第一题 4A
题意:给定一个数w,问能否分成两部分并且每部份都是偶数
思路:w的值很小,暴力枚举两部分的值
代码:
n = int(raw_input())
isOk = False
for i in range(2,n):
if i%2 == 0 and (n-2)%2 == 0:
isOk = True
break
if isOk:
print "YES"
else:
print "NO"
第二题 5A
Polycarp is working on a new project called "Polychat". Following modern tendencies in IT, he decided, that this project should contain chat as well. To achieve this goal, Polycarp has spent several hours in front of his laptop
and implemented a chat server that can process three types of commands:
- Include a person to the chat ('Add'command).
- Remove a person from the chat ('Remove'command).
- Send a message from a person to all people, who are currently in the chat, including the one, who sends the message ('Send'command).
Now Polycarp wants to find out the amount of outgoing traffic that the server will produce while processing a particular set of commands.
Polycarp knows that chat server sends no traffic for 'Add' and 'Remove' commands. When 'Send' command is processed, server sendslbytes to each
participant of the chat, wherelis the length of the message.
As Polycarp has no time, he is asking for your help in solving this problem.
Output
Print a single number — answer to the problem.
题意:有三种命令,"+name"是添加一个人,"-name"是删除一个人,"name:message"是这个人发了message给所有人,问最后总的发送的字节数
思路:直接暴力求解,利用Python的list
代码:
dict = []
sum = 0
# input
while True:
try:
str = raw_input()
except:
break
if str[0] == '+':
dict.append(str[1:])
elif str[0] == '-':
dict.remove(str[1:])
else:
length = len(str)
for i in range(length):
if str[i] == ':':
sum += (length-(i+1))*(len(dict))
break
print sum
第三题 6A
题意:给定4条线段,问能否组成三角形,如果可以输出"TRIANGLE",如果不能组成三角形但是会退化输出"SEGMENT",否则输出"IMPOSSIBLE"
思路:直接暴力枚举
代码:
sticks = raw_input().split()
# 判断能否组成三角形
def isOk(x , y , z):
if x+y > z and x+z > y and y+z > x:
return True
return False
# 判断是否会退化
def judge(x , y , z):
if x+y == z or x+z == y or y+z == x:
return True
return False
# 求ans
ans = "IMPOSSIBLE"
for i in range(4):
for j in range(i+1,4):
for k in range(j+1,4):
if isOk(int(sticks[i]),int(sticks[j]),int(sticks[k])):
ans = "TRIANGLE"
if ans == "IMPOSSIBLE" and judge(int(sticks[i]),int(sticks[j]),int(sticks[k])):
ans = "SEGMENT"
print ans
分享到:
相关推荐
在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]...
开始跟踪: python3 stalk.py 注意:要在python 2上运行,请尝试以下命令: python2 old.py 结果可能需要几秒钟的时间来获取。 希望看到更多的在线评委,或者您喜欢这个项目,并希望随时提出提出请求。
力编码器 无需打开网站即可解决 CodeForces Round 问题! 文档和使用方法即将推出
这种工具可以自动从codeforces找到高质量的Python解决的任务。 我写这个工具是为了帮助我找到好的资源来提高我的 Python 技能。 cd codeforces python solution-finder.py (number of the contest, e.g. 988) ...
解决 CodeForces 问题