diff --git a/daily_problems/2024/03/0306/personal_submission/cf1194d_tsreaper.cpp b/daily_problems/2024/03/0306/personal_submission/cf1194d_tsreaper.cpp new file mode 100644 index 0000000000..e41ad5d3c3 --- /dev/null +++ b/daily_problems/2024/03/0306/personal_submission/cf1194d_tsreaper.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +void solve() { + int n, K; scanf("%d%d", &n, &K); + if (K % 3) { + if (n % 3) printf("Alice\n"); + else printf("Bob\n"); + } else { + n %= K + 1; + if (n % 3 || n == K) printf("Alice\n"); + else printf("Bob\n"); + } +} + +int main() { + int tcase; scanf("%d", &tcase); + while (tcase--) solve(); + return 0; +} diff --git a/daily_problems/2024/03/0306/personal_submission/cf621e_tsreaper.cpp b/daily_problems/2024/03/0306/personal_submission/cf621e_tsreaper.cpp new file mode 100644 index 0000000000..afc9f006ef --- /dev/null +++ b/daily_problems/2024/03/0306/personal_submission/cf621e_tsreaper.cpp @@ -0,0 +1,52 @@ +#include +#define MOD ((int) 1e9 + 7) +using namespace std; + +int n, m, G, X, cnt[10]; + +struct Matrix { + int n, m; + long long V[100][100]; + + Matrix(int n, int m): n(n), m(m) { + for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) V[i][j] = 0; + } + + Matrix operator*(const Matrix &A) const { + Matrix B(n, A.m); + for (int i = 0; i < n; i++) for (int j = 0; j < A.m; j++) for (int k = 0; k < m; k++) + B.V[i][j] = (B.V[i][j] + V[i][k] * A.V[k][j]) % MOD; + return B; + } +}; + +Matrix power(Matrix &A, long long b) { + Matrix Y(A.n, A.n); + for (int i = 0; i < Y.n; i++) Y.V[i][i] = 1; + for (; b; b >>= 1) { + if (b & 1) Y = Y * A; + A = A * A; + } + return Y; +} + +int main() { + scanf("%d%d%d%d", &n, &m, &G, &X); + for (int i = 1; i <= n; i++) { + int x; scanf("%d", &x); + cnt[x]++; + } + + Matrix K(X, X); + for (int i = 0; i < X; i++) for (int j = 1; j <= 9; j++) { + int ii = (i * 10 + j) % X; + K.V[i][ii] = (K.V[i][ii] + cnt[j]) % MOD; + } + K = power(K, m); + + Matrix A(1, X); + A.V[0][0] = 1; + A = A * K; + printf("%lld\n", A.V[0][G]); + return 0; +} diff --git a/records/202403.csv b/records/202403.csv index 58ce82ce2a..d29057cedd 100644 --- a/records/202403.csv +++ b/records/202403.csv @@ -1,7 +1,7 @@ Name, Days with Submissions, Total Submissions Yawn_Sean,4,8 Arrogant_sword,4,5 -TsReaper,4,8 +TsReaper,5,10 retyrn,4,6 ncf,4,4 hum,4,8