a = input()
b = set(input())
ans = ""
for i in a:
if i not in b:
ans += i
print(ans)
import math
a = int(input())
print("2^%d = %d" % (a,math.pow(2,a)))
n = [1]
def de(b):
if b == 1:
return 1;
n.append(b*de(b-1))
return n[b-1]
sum = 0
a = int(input())
de(a)
for i in range(a):
sum += n[i]
print(sum)
print("This is a simple problem.")
a = input().split()
n = int(a[0])
b = a[1]*n
n = n*5
if n % 10 < 5:
n /=10
else:
n = n/10+1
for i in range(int(n)):
print(b)
n = int(input())
a = [7, 9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
b = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2','-1']
f = 0
for i in range(n):
num = input()
sum = 0
for j in range(17):
try:
sum += int(num[j])*a[j]
sum = sum % 11
except:
sum = 11
break
if b[sum] != num[17]:
f = 1
print(num)
if f == 0:
print("All passed")
a = input()
n = int(a)
count = 0
for i in a:
if i == '2':
count+=1
l = len(a)
if n % 2 ==0:
count*=2
if n < 0:
count*=1.5
l -=1
count=count*100/l
print("%.2f%c" % (count,'%'))
a = input()
b = a.split(':')
h = int(b[0])
m = int(b[1])
if h == 12 and m == 0:
h -= 1
if h < 12:
print("Only %s. Too early to Dang." % a)
else:
i = h -12
if m > 0:
i +=1
print("Dang"*i)
测试点3是长整型,不过python不用考虑
测试点4是结果为0,看看是否输出
a,b = map(int,input().split())
num = int(input())
m,n = 0,0
for i in range(num):
x,y,z,j = map(int,input().split())
all = x+ z
if y == all and j != all:
m+=1
if j == all and y != all:
n+=1
if m > a:
print('A')
print(n)
break
if n > b:
print('B')
print(m)
break
n = int(input())
a = set()
for i in range(n):
b = input().split()[1:]
if len(b) != 1:
a.update(b)
m = int(input())
b = input().split()
f = 0
c = []
for i in b:
if i not in a:
f = 1
a.add(i)
c.append(i)
if f == 0:
print("No one is handsome",end='')
else:
print(" ".join(c))
我不是很理解为什么有时候过了,有时候非0返回,不过感觉加try的ac概率高。
import java.io.*;
public class Main {
private final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
try {
String s= br.readLine();
String b = String.format("[%s]", br.readLine());
System.out.println(s.replaceAll(b, ""));
} catch (Exception e) {
}
}
}
import java.util.Scanner;
public class Main {
private final static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int i = sc.nextInt();
System.out.printf("2^%d = %d%n",i,(int)Math.pow(2,i));
}
}
import java.util.Scanner;
public class Main {
private final static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int ans = 0;
int count = 1;
for (int i = 1; i <= n; i++) {
count *= i;
ans += count;
}
System.out.println(ans);
}
}
public class Main {
public static void main(String[] args) {
System.out.println("This is a simple problem.");
}
}
import java.util.Scanner;
import java.io.*;
public class Main {
private final static Scanner sc = new Scanner(System.in);
private final static PrintWriter print = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
int n = sc.nextInt();
String s = sc.next().repeat(n);
for (int i = 0; i < n*1.0/2; i++) {
print.println(s);
}
print.flush();
}
}
import java.io.*;
public class Main {
private final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static int[] num = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
static char[] b = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
public static void main(String[] args) throws IOException {
int n = Integer.parseInt(br.readLine());
boolean f = true;
for (int i = 0; i < n; i++) {
String s = br.readLine();
if (!check(s)) {
f = false;
System.out.println(s);
}
}
if (f) {
System.out.println("All passed");
}
}
private static boolean check(String s) {
int sum = 0;
for (int i = 0; i < s.length() - 1; i++) {
int j = s.charAt(i) - '0';
if (j < 0 || j > 9)
return false;
sum += num[i]*j;
}
return b[sum % 11] == s.charAt(s.length() - 1);
}
}
import java.io.*;
public class Main {
private final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
String s = br.readLine();
String replace = s.replace("2", "");
double i = 100;
if (s.startsWith("-")){
i *= 1.5;
i *= 1-(replace.length()-1)*1.0/(s.length()-1);
}else{
i *= 1-replace.length()*1.0/s.length();
}
System.out.printf("%.2f%%\n",i *((s.charAt(s.length()-1)-'0')%2==0?2:1));
}
}
import java.io.*;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class Main {
private final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
String s = br.readLine();
LocalTime time = LocalTime.parse(s, DateTimeFormatter.ofPattern("HH:mm"));
if (time.isBefore(LocalTime.of(12,1))){
System.out.printf("Only %s. Too early to Dang.%n",s);
}else{
int h = time.getHour()-12;
int m = time.getMinute();
if (m>0){
h++;
}
for (int i = 0; i < h; i++) {
System.out.print("Dang");
}
System.out.println();
}
}
}
import java.io.*;
public class Main {
private final static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public static int nextInt() throws IOException {
st.nextToken();
return (int) st.nval;
}
public static String next() throws IOException {
st.nextToken();
return st.sval;
}
public static void main(String[] args) throws IOException {
int a = nextInt();
int b = nextInt();
int x = a, y = b;
int n = nextInt();
for (int i = 0; i < n; i++) {
int x_han = nextInt(), x_hua = nextInt(), y_han = nextInt(), y_hua = nextInt();
int he = x_han + y_han;
if (he != x_hua && he != y_hua || he == x_hua && he == y_hua) {
continue;
}else if (he == x_hua) {
x--;
} else {
y--;
}
if (x < 0) {
System.out.println("A");
System.out.println(b-y);
break;
}
if (y < 0) {
System.out.println("B");
System.out.println(a-x);
break;
}
}
}
}
这个题最后一个测试超时,也没啥办法试过很多了。
stream流啥的在这种小数据还慢些,哎。
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
public class Main {
private final static PrintWriter print = new PrintWriter(new OutputStreamWriter(System.out));
private final static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
HashSet<String> set = new HashSet<>();
int n = Integer.parseInt(br.readLine());
for (int i = 0; i < n; i++) {
String[] s = br.readLine().split(" ");
if (s.length == 2)
continue;
//for (int j = 1; j < s.length; j++)
// set.add(s[j]);
set.addAll(Arrays.asList(s));
//set.addAll(Arrays.asList(s).subList(1, s.length)););
}
br.readLine();
boolean f = false;
String[] s = br.readLine().split(" ");
// String[] array = Arrays.stream(s).filter(set::add).toArray(String[]::new);
// if (array.length == 0)
// print.print("No one is handsome");
// else
// print.print(String.join(" ", array));
for (String x : s) {
if (set.add(x)) {
if (f)
print.print(" ");
f = true;
print.print(x);
}
}
if (!f)
print.print("No one is handsome");
print.println();
print.flush();
}
}