Codeforces Round #382 (Div. 2) 继续python作死

A - Ostap and Grasshopper

zz题能不能跳到  每次只能跳K步 不能跳到# 问能不能T-G  随便跳跳就可以了  第一次居然跳越界0.0  傻子哦  WA1

n,k = map(int,input().split())
s = input()
i = 0
st = -1
def jump(st):
    while(st<n):
        st+=k
        if(st>=n or s[st]==‘#‘):
            return "NO"
        if(s[st]==‘T‘ or s[st]==‘G‘):
            return "YES"
    return "NO"
while(i<n):
    if(s[i]==‘T‘ or s[i]==‘G‘):
        if(st==-1):
            st=i
            break
    i+=1
print(jump(st))

PY

B - Urbanization

均值之和最大  贪心  最大的放在小部分 我们可以反证  交换任意的人在两个city  会使情况变坏

n,x,y = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
if(x>y):
    x,y = (y,x)
cx = 0
cy = 0
m,n = (x,y)
for i in a:
    if(x>0):
        x-=1
        cx+=i
    elif(y>0):
        y-=1
        cy+=i
    else:
        break
print(cx/m+cy/n)

PY

C - Tennis Championship

相差一场的可以比赛 那么最优的是相隔一次n,n+1 能产生n+2的  所以就是斐波那契了  这题ZZ

n = eval(input())
a = [0]*100
a[0] = 1
a[1] = 2
for i in range(2,100):
    a[i]=a[i-1]+a[i-2]
    if(a[i]>n):
        n = i-1
        break
print(n)

PY

D - Taxes

问能分解为质数的最少个数 答案就三种 1 2 3 我们先考虑本身为质数的 ans = 1
 不是质数但是是偶数的 哥德巴赫猜想   ans = 2

不是质数但是是奇数 如果他能有两个质数组成  那么其中一个一定是2 只需要判断n-2 是否为素数即可 ans = 2

否则的话就是ans = 3

然后就AC了...这套题的前四个有点水啊.... 但是还是累计wa3发

import math

n = eval(input())
def isP(n):
    lim = int(math.sqrt(n + 0.5))
    for i in range(2,lim+1):
        if(n%i==0):
            return False
    return True
ans = 0
if(isP(n)):
    ans = 1
elif(n%2==0):
    ans = 2
elif(isP(n-2)):
    ans = 2
else:
    ans = 3
print(ans)

AC代码

E

F

待补

时间: 2024-08-09 23:53:20

Codeforces Round #382 (Div. 2) 继续python作死的相关文章

Codeforces Round #455 (Div. 2) C. Python Indentation dp递推

Codeforces Round #455 (Div. 2) C. Python Indentation 题意:python 里面,给出 n 个 for 循环或陈述语句,'f' 里面必须要有语句.按 python 缩进的方式组合成合法的程序,问有多少种可能方案. tags: dp dp[i][j] 表示第 i 个语句缩进为 j 时的可能方案数, 转移: 1] 如果第 i 个是 'f' , 则第 i+1 个肯定要比第 i 个多缩进一个单位,即 dp[i+1][j] = dp[i][j]. 2]如果

Codeforces Round #382 (Div. 2)

A题,水题. B题,贪心一发.排序一下,从大到小,先拿个数较少的几个,再拿个数较多的几个即可.证明应该是显而易见的. C题,本以为log一发即可.但是log的话不能保证深度最深,即不能保证最大分数最大.因此考虑递推,用f[i]表示要得到i分需要的最少的人数,显然要人数最少,最后剩下一个即可.那么要得到f[i],只要分数为i-1和分数为i-2的两个人进行比赛即可,只要i-1胜最后肯定只有最后一个人了.因此得到f[i]=f[i-1]+f[i-2].所以做法是先做递推的预处理,然后二分查找一下最大的x

codeforces736b Taxes (Codeforces Round #382 (Div. 1))

题意:纳税额为金额的最大因数(除了本身).为了逃税将金额n分为n1+n2+.......问怎样分纳税最少. 哥德巴赫猜想: 任一大于2的偶数都可写成两个质数之和. 质数情况: 任何大于5的奇数都是三个素数之和 因此,如果n是偶数,结果就是2. 如果n是奇数.奇数只能拆成一奇一偶.分为2种情况.一偶是2时,那么如果一奇是质数,结果为2.如果一奇不是质数,那么结果至少为3,由于哥德巴赫猜想,3一定可行的,因此结果就是3. 一偶不是2时,一偶至少要交税2,一奇至少交税1,同样由猜想,结果为3. //#

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

Codeforces Round #264 (Div. 2)[ABCDE]

Codeforces Round #264 (Div. 2)[ABCDE] ACM 题目地址: Codeforces Round #264 (Div. 2) 这场只出了两题TAT,C由于cin给fst了,D想到正解快敲完了却game over了... 掉rating掉的厉害QvQ... A - Caisa and Sugar[模拟] 题意: Caisa拿s美元去超市买sugar,有n种sugar,每种为xi美元yi美分,超市找钱时不会找美分,而是用sweet代替,当然能用美元找就尽量用美元找.他

Codeforces Round #356 (Div. 2) [Codeforces680]

此处有目录↑ Codeforces Round #356(Div. 2):http://codeforces.com/contest/680 A. Bear and Five Cards (贪心) time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little bear Limak plays a game. He has

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i

Codeforces Round #424 (Div. 2) D. Office Keys(dp)

题目链接:Codeforces Round #424 (Div. 2) D. Office Keys 题意: 在一条轴上有n个人,和m个钥匙,门在s位置. 现在每个人走单位距离需要单位时间. 每个钥匙只能被一个人拿. 求全部的人拿到钥匙并且走到门的最短时间. 题解: 显然没有交叉的情况,因为如果交叉的话可能不是最优解. 然后考虑dp[i][j]表示第i个人拿了第j把钥匙,然后 dp[i][j]=max(val(i,j),min(dp[i-1][i-1~j]))   val(i,j)表示第i个人拿

Codeforces Round #424 (Div. 2) C. Jury Marks(乱搞)

题目链接:Codeforces Round #424 (Div. 2) C. Jury Marks 题意: 给你一个有n个数序列,现在让你确定一个x,使得x通过挨着加这个序列的每一个数能出现所有给出的k个数. 问合法的x有多少个.题目保证这k个数完全不同. 题解: 显然,要将这n个数求一下前缀和,并且排一下序,这样,能出现的数就可以表示为x+a,x+b,x+c了. 这里 x+a,x+b,x+c是递增的.这里我把这个序列叫做A序列 然后对于给出的k个数,我们也排一下序,这里我把它叫做B序列,如果我