#学习笔记
#用以练习Python基础
#
Original title Link: https://www.patest.cn/contests/pat-b-practise/1011
1011. A+b and C (15)
for 3 integers a, b, and C within a given interval [-2 to 2 31], determine if A+B is greater than C.
Input format:
Enter line 1th to give the positive integer t (<=10), which is the number of test cases. The T-group test cases are then given, one row for each group, and a, B, and C in order. The integers are separated by a space.
Output format:
For each set of test cases, output "case #X: True" in one row if a+b>c, otherwise the output is "case #X: false", where X is the number of the test cases (starting at 1).
Input Sample:
41 2 32 3 42147483647 0 21474836460-2147483648-2147483647
Sample output:
Case #1: falsecase #2: truecase #3: truecase #4: False
AC Code
N=int (input ()) for I in Range (n): L=str (Input ()). Split (") if (int (l[0)) +int (l[1]) >int (l[2)): Print (' case #%d:true '% (i+1)) else:print (' Case #%d:false '% (i+1))
#原题链接: https://www.patest.cn/contests/pat-b-practise/1061
1061. Judgment title (15)
Judging the judgment is very simple, the question asks you to write a simple procedure to help the teacher to judge the problem and statistics of the students score.
Input format:
The input gives two positive integers not exceeding 100 N and M in the first row, respectively, the number of students and the quantity of judgment questions. The second line gives a positive integer of M not more than 5, which is the full value of each question. The third line gives the correct answer to each question, 0 means "non" and 1 means "yes". Then n rows, each line gives a student's answer. The numbers are separated by spaces.
Output format:
Output each student's score in the order entered, with each score occupying one line.
Input Sample:
3 62 1 3 3 4 50 0 1 0 1 10 1 1 0 0 11 0 1 0 1 01 1 0 0 1 1
Sample output:
131112
AC Code
L=STR (Input ()). Split (') n=l[0]; M=L[1]T=0L1=STR (Input ()). Split (') L2=str (input ()). Split (") for I in range (int (N)): L=str (Input ()). Split (") for J In range (int (M)): if (L[j]==l2[j]): T=t+int (L1[j]) print (T) t=0
Original title Link: https://www.patest.cn/contests/pat-b-practise/1063
1063. Calculate spectral radius (20)
In mathematics, the "spectral radius" of a matrix refers to the upper bound of the modulus set of its eigenvalues. In other words, for a given n complex space eigenvalues {a1+b1i, ..., an+bni}, their modulus is the square sum of the real part and the imaginary part, and the "Spectral radius" is the maximum modulus.
Now given the eigenvalues of some complex spaces, you should calculate and output the spectral radii of these eigenvalues.
Input format:
Enter the first line to give a positive integer n (<= 10000) is the number of input eigenvalues. Then n rows, each row gives the real and imaginary parts of 1 eigenvalues, separated by a space. Note: The title guarantees that both real and imaginary parts are integers with absolute values not exceeding 1000.
Output format:
The spectral radius is output in a row, rounding retains 2 digits after the decimal point.
Input Sample:
50 12 0-1) 03 30-3
Sample output:
4.24
Import mathn=int (input ()) Max1=-1for I in Range (N): l=list (str (input ()). Split (")) l=[float (i) for i in L] X=math . sqrt (Math.pow (l[0],2) +math.pow (l[1],2)) if x > Max1:max1=xprint ('%.2f '% max1)
This article is from the "Chauncey" blog, make sure to keep this source http://cqwujiang.blog.51cto.com/10808946/1919684
Python Basics Exercises Pat Water question (ii)