-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Second update as of 3 September 2024
- Loading branch information
1 parent
e4006f3
commit b048d06
Showing
8 changed files
with
496 additions
and
236 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
input();m=10**9+7;a=1;b=c=0;s=[*map(int,input())] | ||
for i in s:t=[a,b,c];a,b,c=(a+t[-i%3])%m,(b+t[(1-i)%3])%m,(c+t[(2-i)%3])%m | ||
print((a-pow(2,s.count(0),m))%m) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
n = [*map(int, input())]; t = None | ||
for i in range(len(n)-1, -1, -1): | ||
if t: continue | ||
if n[i]: | ||
for j in range(i-1, -1, -1): | ||
if n[j] < 9: t = (i, j); break | ||
if t: n[t[0]] -= 1; n[t[1]] += 1; n[t[1]+1:] = sorted(n[t[1]+1:]) | ||
else: | ||
s = sum(n)-1; n = [1]+[0]*len(n); p = len(n)-1 | ||
while s: u = min(9, s); s -= u; n[p] = u; p -= 1 | ||
print(''.join(map(str, n))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
def check(): | ||
if len(z) < len(t): return 0 | ||
for i in range(len(t)): | ||
if t[i] != z[i-len(t)]: return 0 | ||
return 1 | ||
s, t = input(), input(); z = [] | ||
for i in s: | ||
z.append(i) | ||
if check(): | ||
for _ in range(len(t)): z.pop() | ||
print(''.join(z) or 'FRULA') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
while(p:=int(input())): | ||
if p==2:print('Impossible');continue | ||
v=[1]*p | ||
for i in range(p):v[i*i%p]=0 | ||
print(''.join(map(str,v[1:]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys; sys.setrecursionlimit(10**5) | ||
m = 998244353 | ||
a = [*map(int, input())] | ||
b = [*map(int, input())] | ||
a = [0]*(len(b)-len(a))+a | ||
a[-1] -= 1; p = len(a)-1 | ||
while a[p] < 0: a[p] += 10; a[p-1] -= 1; p -= 1 | ||
|
||
def f(x): | ||
n = len(x) | ||
def bt(pos, prev, tie): | ||
if pos == n: return 1 | ||
if tie: return pow(9, n-pos, m) | ||
s = 0 | ||
for u in range(x[pos]): | ||
if u == prev: continue | ||
s += bt(pos+1, u, 1) | ||
if x[pos] != prev: s += bt(pos+1, x[pos], 0) | ||
return s%m | ||
return bt(0, -1, 0)%m | ||
print((f(b)-f(a))%m) |