Enormous Input Test Solved Problem code: INTEST

import sys
import psyco #一键优化库
psyco.full()

def main():
    n, k = map(int, sys.stdin.readline().strip().split()) #两位数输入的复用
    count = 0
    for t in sys.stdin: #注意这个for循环方式
        if int(t) % k == 0:
            count += 1
    print ‘%d‘ % count #注意格式输出

main() #写成函数的格式是一个良好的习惯

学到

  python强大

    有一键算法优化的库

  复用

    map这种

  循环控制

  格式输出

  函数构成

错误

  ++和C里面的不一样

  

时间: 2024-10-24 08:58:39

Enormous Input Test Solved Problem code: INTEST的相关文章

ATM Solved Problem code: HS08TES

1 # ATM 2 import sys 3 4 withdraw, balance = map(float, sys.stdin.readline().strip().split()) # strip()用法去除结尾的\n符号 5 6 if int(withdraw) % 5 != 0 or balance < (withdraw + 0.5): # 1.注意手续费,缺少手续费也不能取 2.xy0~2000是测试值要求,不用判断 7 print("%.2f" % balance

Small factorials Solved Problem code: FCTRL2

1 import sys 2 3 4 def fact(n): 5 final = n 6 while n > 1: 7 final *= n - 1 8 n -= 1 9 return final #逻辑严谨,不要忘了return 10 11 12 def main(): 13 t = int(sys.stdin.readline()) 14 for n in sys.stdin: 15 print fact(int(n)) #读取String的转换是一个常见的坑 16 17 18 main(

Factorial Solved Problem code: FCTRL

1 import sys 2 #import psyco #很奇怪,这题用psyco就runtime error 3 4 5 #psyco.full() 6 7 8 def z(n): #这个应该是技巧的一种算法 9 r = 0 10 while 5 <= n: 11 n /= 5 12 r += n 13 return r 14 15 16 def main(): 17 n = int(sys.stdin.readline()) 18 for t in sys.stdin: #这种循环输入一点

codechef Enormous Input Test 快速读入数据 fread

本题就是测试读入数据的速度的. 如果有大量的数据读入,使用cin是很慢的. 那么使用scanf那么会快很多,但是如果数据量更大的话那么就还是不够快了. 所以这里使用fread. 首先开一个buffer,然后使用fread大块大块地读入数据就可以非常快地读入了. 题目如下: Input The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive

【CodeChef】Enormous Input Test

The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data p

Chef and Prime Divisors Problem code: CHAPD (GCD问题)

题目大意: 给定两个数,n,m,找到如果m的所有质因数可以被n,整处的话输出"Yes",OR   "No". text: 3 120 75 128 16 7 8 Output: Yes Yes No 直到,最大公约数为1,时看后者是否为1,即可. #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<c

Turbo Sort Add problem to Todo list Problem code: TSORT

1 def heap_sort(ary): 2 n = len(ary) # 8 3 first = int(n / 2 - 1) # 3 4 for start in range(first, -1, -1): # 3~0 revese 5 max_heapify(ary, start, n - 1) # from start 6 for end in range(n - 1, 0, -1): 7 ary[end], ary[0] = ary[0], ary[end] 8 max_heapif

Holes in the text Add problem to Todo list Problem code: HOLES

1 import sys 2 3 4 def count_holes(letter): 5 hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R'] 6 if letter == 'B': 7 return 2 8 elif letter in hole_2: 9 return 1 10 else: 11 return 0 12 13 14 def main(): 15 n = int(sys.stdin.readline()) 16 for t in sys.stdin:

The Lead Game Add problem to Todo list Problem code: TLG

1 '''def count_lead(first, second): 2 if first > second: 3 return 1, first - second 4 elif first == second: # 题目中没有说明相等的情况 5 return 0, 0 6 else: 7 return 2, second - first''' 8 9 10 def main(): 11 n = int(raw_input()) 12 lead = 0 13 winner = 0 # 有些初始