登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

AP计算机众里寻他千百度,名师成就满分路

AP计算机

 
 
 

日志

 
 
关于我

大学讲师,中国首批AP计算机教师,著有中国第一套,历经五年实践证明深受学生欢迎的成功的AP计算机双语教材,2013年以93%的满分率开创了中国AP计算机成功的先河,远远超出全美26.6%的满分率,为中国AP计算机教学树立了典范,并在同年加拿大计算机竞赛中勇夺桂冠,任教学生获哥伦比亚大学,麻省理工学院,卡耐基梅隆大学,宾夕法尼亚大学,康奈尔大学,西北大学等学校录取,远程学生遍及北京、长春、南京、重庆、广州、济南, 深圳、成都、费城,洛杉矶,加州,宾州,新罕布什尔州等地,希望借此平台为信息技术的发展做出贡献!

2016年加拿大计算机竞赛 深圳中学吕沛霖提供  

2016-05-30 14:02:09|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
CCC2016J1
# coding:utf-8
wins = 0
for _ in range(6):
    wins += 1 if input().find('W') != -1 else 0
if wins == 0:
    print('-1')
elif wins == 1 and wins == 2:
    print('3')
elif wins == 3 and wins == 4:
    print('2')
elif wins == 5 and wins == 6:
    print('1')
CCC2016J2
# coding:utf-8
square = list()
for _ in range(4):
    square.append(list(map(int, input().split())))
magic = True
testsum = sum(square[0])
for i in range(4):
    if sum(square[i]) != testsum or sum(line[i] for line in square) != testsum:
        magic = False
        break
print('magic' if magic else 'not magic')

CCC2016J3

def ispal(s):
    halfl = len(s) // 2
    return s[:halfl] == ''.join(reversed(s[len(s) - halfl:]))

line = input()
l = len(line)
maxl = 1
for length in range(1, l + 1):
    for start in range(l - length + 1):
        substr = line[start:start + length]
        if ispal(substr):
            maxl = max(maxl, len(substr))
print(maxl)

CCC2016J4
# coding:utf-8
def string2time(s: str):
    spl = s.split(':')
    return int(spl[0]) * 60 + int(spl[1])


def inrush(t: int):
    return (t >= 420 and t < 600) or (t >= 900 and t < 1140)

totalt = 0
apart = string2time(input())
while totalt < 120:
    totalt += 5 if inrush(apart) else 10
    apart = (apart + 10) % 1440
print(str(apart // 60).rjust(2, '0') + ':' + str(apart % 60).rjust(2, '0'))

CCC2016J5
# coding:utf-8
qtype = input()
n = int(input())
citya = list(map(int, input().split()))
cityb = list(map(int, input().split()))
total = sorted(citya + cityb, reverse=True)
if qtype == '1':
    print(sum(total[::2]))
else:
    print(sum(total[:len(total) // 2]))


from collections import Counter
#import sys
# INPUTFILE=sys.stdin  #从键盘读
INPUTFILE = open('s1.in', 'r')  # 从文件读


def input():
    return INPUTFILE.readline().strip()


cccrocks
socc*rk*
if __name__ == '__main__':
    line1 = Counter(input())
    line2 = Counter(input())
    line2.pop('*', None)
    line1.subtract(line2)
    print('N' if any(i < 0 for i in line1.values()) else 'A')

2
5
202 177 189 589 102
17 78 1 496 540
#import sys
# INPUTFILE=sys.stdin  #从键盘读
INPUTFILE = open('s2.in', 'r')  # 从文件读


def input():
    return INPUTFILE.readline().strip()


if __name__ == '__main__':
    qtype = input()
    n = int(input())
    citya = list(map(int, input().split()))
    cityb = list(map(int, input().split()))
    total = sorted(citya + cityb, reverse=True)
    if qtype == '1':
        print(sum(total[::2]))
    else:
        print(sum(total[:len(total) // 2]))

8 2
5 2
0 1
0 2
2 3
4 3
6 1
1 5
7 3
# coding:utf-8

#import sys
# INPUTFILE=sys.stdin  #从键盘读
INPUTFILE = open('s3.in', 'r')  # 从文件读


def input():
    return INPUTFILE.readline().strip()


class Graph(dict):

    def addnode(self, node):
        self[node] = set()

    def addedge(self, node1, node2):
        self[node1].add(node2)
        self[node2].add(node1)

    def findpath(self, start, end, path=[]):
        """ *不包括* 终点的路径"""
        if start in path:
            return None
        if start == end:
            return path
        path = path.copy()
        path.append(start)
        for adj in self[start]:
            r = self.findpath(adj, end, path)
            if r is not None:
                return r


def solve(graph, current, plan, path=[]):
    """current: 现在位置, plan: 还没去的地方, path: 走过的路"""
    global presult
    if len(plan) == 0:
        presult.append(path)
        return
    for p in plan:
        newplan = plan.copy()
        newplan.remove(p)
        solve(graph, p, newplan, path + graph.findpath(current, p))


if __name__ == '__main__':
    line1 = input().split()
    n = int(line1[0])  # total restaurants
    m = int(line1[1])  # num Pho restaurants
    phos = set(map(int, input().split()))

    waterloo = Graph()
    for p in range(n):
        waterloo.addnode(p)
    for _ in range(n - 1):
        line = input().split()
        waterloo.addedge(int(line[0]), int(line[1]))

    minpath = 100000
    for p in phos:
        newphos = phos.copy()
        newphos.remove(p)
        presult = list()
        solve(waterloo, p, newphos)
        minpath = min(minpath, min(map(len, presult)))

    print(minpath)
7
47 12 12 3 9 9 3
#import sys
# INPUTFILE=sys.stdin  #从键盘读
INPUTFILE = open('s4.in', 'r')  # 从文件读


def input():
    return INPUTFILE.readline().strip()


if __name__ == '__main__':
    presult = list()

    def combiner(row):
        global presult
        cancmb = False
        for i in range(len(row) - 1):
            if row[i] == row[i + 1]:
                cancmb = True
                newrow = row[:i] + [row[i] * 2] + row[i + 2:]
                combiner(newrow)
        for i in range(len(row) - 2):
            if row[i] == row[i + 2]:
                cancmb = True
                newrow = row[:i] + [row[i] * 2 + row[i + 1]] + row[i + 3:]
                combiner(newrow)
        if not cancmb:
            presult.append(row)

    n = int(input())
    rice = list(map(int, input().split()))
    combiner(rice)
    maxrice = 0
    for result in presult:
        maxrice = max(maxrice, max(result))
    print(maxrice)
7 4
0000001
#import sys
# INPUTFILE=sys.stdin  #从键盘读
INPUTFILE = open('s5.in', 'r')  # 从文件读


def input():
    return INPUTFILE.readline().strip()


if __name__ == '__main__':
    line1 = input().split()
    n = int(line1[0])  # num cells
    t = int(line1[1])  # num generations
    line2 = input()
    cells = list(map(lambda x: bool(int(x)), line2))
    for _ in range(t):
        nextgen = list()
        for i in range(n):
            nextgen.append(True if cells[(i - 1) % n] != cells[(i + 1) % n] else False)
        cells = nextgen
    print(''.join(map(lambda x: '1' if x else '0', cells)))
  评论这张
 
阅读(346)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018