Caesar Cipher B
description
Caesar Cipher is the Roman Julius Caesar used to be military intelligence encryption algorithm, which uses an alternative method for each English character cycle information with a third character behind the character alphabet sequence, namely, correspondence relationship alphabet as follows:
原文: ABCDEFGHIJKLMNOPQRSTU VWXYZ
密文: ABC
For the original character P, the character ciphertext C which satisfy the following conditions: C = (P + 3) mod 26
The above is Caesar cipher encryption method, decryption method and vice versa, i.e.: P = (C-3) mod 26
Assume that the user may use the input contains only the Letter, i.e., the English lowercase letters a ~ zA ~ Z and special characters, write a program, the input string Caesar cipher encryption, a direct output, wherein the special characters are not encrypted deal with.
This topic is Auto OJ (auto reviewers) type, please note:
1. Enter using the input ( ""), not to increase the message
2. The output
3. Enter the case is not
Entry
Example 1: python is GOOD!
Export
Example 1: sbwkrq lv JRRG!
s = input() t = "" for c in s: if 'a' <= c <= 'z': t + = CHR (words ( ' a ' ) + ((word (c) signal words ( ' a ' )) + 3 )% 26 ) elif 'A'<=c<='Z': t + = CHR (words ( ' A ' ) + ((word (c) signal words ( ' A ' )) + 3 )% 26 ) else : t += c print(t)
03200301584982791069
A paired brackets detection
description
The user input string line, which may include the parentheses (), check whether the parentheses are correctly paired, pairing success outputs:
The pairing is successful, unsuccessful pairing
Wherein paired parentheses to consider matching sequence, i.e., () indicates pairing) (not paired, pairing only consider parentheses.
Note that this is a topic OJ, get input using input ( "").
Entry
Example 1] This is an example)
Example 2: This is a (example
Export
Example 1: the pairing is successful
Example 2: unsuccessful pairing
s = input("") t = {'('} r = {')'} a = 0 b = 0 for c in s: if c in t: a = a+1 if c in r: b = b+1 else: a = a+0 b = b+0 elif a>b: if c in r: b = b+1 else: a = a+0 b = b+0 if (a+b)%2 == 0: Print ( " pairing successful " ) the else : Print ( " pairing unsuccessful " )
With math symbols
description
Read an integer N, the following are calculated:
1. N absolute value;
2. N with symbols for addition, subtraction, multiplication and 10, referring to the same operation using the symbol N and the absolute value calculates another number, the absolute value of the calculation result are given the same reference numerals N, wherein symbol 0 is a positive number .
The results in the above-described four output line, a blank-separated outputs are integers.
Entry
Example 1: 100
Export
Example 1: 100110901000
N = eval(input()) a = abs(N) if N<0: print(a,-abs(a+10),-abs(a-10),-abs(a*10)) else: print(a, abs(a+10), abs(a-10), abs(a*10))
Happy Digital
description
Write an algorithm to determine whether a number is "happy." Happy figure is determined as follows: starting from a positive integer, with each square of which number and the number of substituents, and repeat the process until the final digital convergence or equal to 1 and equal to 1 has been, or will cycle endlessly and ultimately will not go convergence equal to 1. 1 can equal the number of final convergence is a happy number.
For example: figure 19 is a happy, calculated as follows:
- 12 + 92 = 82
- 82 + 22 = 68
- 62 + 82 = 100
- 12 + 02 + 02 = 1
When happy when digital input, output True, otherwise output False.
Entry
Example 1:19
Export
Example 1: True
def getSumofSquares(num): numStr = str (number) sum=0 digitls=[int(x) for x in numStr] for i in digitls: sum + = i ** 2 return sum def main(): n = input() sumofSqrs = eval(n) count = 0 while sumofSqrs != 1: SumofSqrs = GetSumofSquares (SumofSqrs) count += 1 if count > 2000: print("False") break else: print("True") main()
A code string trans
description
Definition string is inverted: the inverted character string consisting of character string included.
Anti-character code is defined as:
(1) The lower-case characters, its inverse is also a lower-case characters, and the characters 'a' is equal to the distance of the inverted 'z' distance;
(2) For the capital English characters, its inverse is also a capital English characters, and the characters from 'A' is equal to the distance which the inverted and 'Z' is;
It refers to a difference from the two characters corresponding unicode encoded.
s = input() t = "" for c in s: if 'a'<=c<='z': t + = CHR (words ( ' Z ' ) signal words (c) + words ( ' a ' )) elif 'A'<=c<='Z': t + = CHR (words ( ' Z ' ) signal words (c) + words ( ' A ' )) else : t = t+c print(t)
03200301584982992727
String in reverse output
description
A user input string, descending output.
Input Format
Enter a string
Output Format
Reverse a
Example O
Entry | Export | |
Example 1 | hello | olleh |
S = input() print(S[::-1])
2003200301584983041887
Zhaomaohuahu factorial
description
Is the factorial Keystone Carman (Christian Kramp) 1808 of the operational sign of the invention, a mathematical terms.
A positive integer factorial (factorial) is the product of all positive integers less than and equal to the number, and 0 is 1 factorial. Writing the factorial of a natural number n n !.
Any natural number greater than or equal to n factorial representation 1:
Reference example code, any program seeking factorial integer greater than zero.
n = int(input()) #把用户输入赋值给变量n,int()的作用是将输入的字符串转成整数 sum = 0 #sum 赋初值为0 for i in range(1,n+1): #括号里取值范围是从1到n,不包括n+1 sum = sum + i #每次循环时把i值加到sum上 print(sum)
Input Format
Enter a positive integer (greater than 0 only consider the case of no need to consider the input is zero)
Output Format
Factorial value, a positive integer
Example O
Entry | Export | |
Example 1 | 5 | 120 |
n = int(input()) sum = 1 for i in range(1,n+1): sum = sum*i print(sum)