Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ff889b

Browse files
Create shopee.md
1 parent 30810c0 commit 1ff889b

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

‎src/shopee.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
```python
2+
"""第一题千分位"""
3+
4+
n = input()[::-1]
5+
if not n or len(n) == 0:
6+
print('')
7+
else:
8+
if n[-1] == '-':
9+
n = n[:-1]
10+
tmp = []
11+
for i in range(0, len(n), 3):
12+
tmp.append(n[i:i+3])
13+
# print(tmp)
14+
print('-'+','.join(i[::-1] for i in tmp[::-1]))
15+
else:
16+
tmp = []
17+
for i in range(0, len(n), 3):
18+
tmp.append(n[i:i + 3])
19+
20+
print(','.join(i[::-1] for i in tmp[::-1]))
21+
22+
23+
24+
25+
"""第二题通配符"""
26+
p = input()
27+
s = input()
28+
29+
30+
def isMatch(s, p):
31+
def helper(s, i, p, j):
32+
if j == -1:
33+
return i == -1
34+
if i == -1:
35+
if p[j] == '*' or p[j] == '#':
36+
return helper(s, i, p, j - 1)
37+
return False
38+
if p[j] == '*':
39+
return helper(s, i - 1, p, j) or helper(s, i, p, j-1)
40+
if p[j] == '#':
41+
return helper(s, i - 1, p, j-1) or helper(s, i, p, j - 1)
42+
if p[j] == '?' or p[j] == s[i]:
43+
return helper(s, i - 1, p, j - 1)
44+
return False
45+
46+
return helper(s, len(s) - 1, p, len(p) - 1)
47+
# print(1 if isMatch(s, p) else 0)
48+
49+
50+
tmp = [['a?c', 'abc'], ['a?c', 'ac'], ['a#c', 'ac'], ['a#c', 'abc'], ['a#c', 'abbc'], ['a*c', 'ac'],
51+
['a*c', 'abc'], ['a*c', 'abbc'], ['a*c', 'abd'], ['a?c#e*f', 'abcdef'], ['a?c#e*f', 'acdef']]
52+
# for i in tmp:
53+
# p, s = i[0], i[1]
54+
# print(1 if isMatch(s, p) else 0)
55+
56+
print(1 if isMatch(s, p) else 0)
57+
"""
58+
输出应该为:
59+
1
60+
0
61+
1
62+
1
63+
0
64+
1
65+
1
66+
1
67+
0
68+
1
69+
0
70+
"""
71+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /