Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int ans[52] = {0, 0, 3, 3, 3, 15, 3, 3, 29, 17, 255, 5, 83, 4095, 43, 3, 63, 15, 63, 63, 1023, 63, 3, 63, 27, 15, 4095, 39, 4095, 5, 83, 15, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const int a[51][4] = { {0, 0, 0, 0}, {0, 0, 0, 0}, {2, 1, 0, 0}, {3, 1, 0, 0}, {4, 1, 0, 0}, {5, 2, 0, 0}, {6, 1, 0, 0}, {7, 1, 0, 0}, {8, 4, 3, 2}, {9, 4, 0, 0}, {10, 3, 0, 0}, {11, 2, 0, 0}, {12, 6, 4, 1}, {13, 4, 3, 1}, {14, 5, 3, 1}, {15, 1, 0, 0}, {16, 5, 3, 2...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int k, P, tail; long long int prime[1000000], chklist[100000], X; struct matrix { int a[51][51]; } matmp, matans, mat, mat0[52]; void find_prime() { int i, j; for (i = 2; (long long int)i * (long long int)i <= X; i++) { if (X % i) continue; for (j = 1; j <= P; j++) if (i % p...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int n; int answer[52][52] = {{0}, {0}, {2, 1}, {3, 2}, {4, 3}, {5, 3}, {6, 5}, {7, 6}, {8, 6, 5, 4}, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int co[] = { 3, 3, 3, 3, 15, 27, 15, 29, 27, 27, 23, 83, 27, 43, 23, 45, 15, 39, 39, 83, 39, 57, 43, 27, 15, 71, 39, 83, 23, 83, 15, 197, 83, 281, 387, 387, 83, 99, 147, 57, 15, 153, 89, 101, 27, 449, 51, 657, 113, 29,...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long P[55] = {0, 0, 3, 5, 12, 20, 48, 106, 177, 318, 931, 17...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int MaxN = 51, MaxC = 0x3F3F3F3F, NA = -1; const char c[MaxN][MaxN] = { {0}, {0}, {1, 1}, {0, 1, 1}, {0, 0, 1, 1}, {1, 0, 1, 1, 1}, {1, 0, 1, 1, 0, 1}, {0, 1, 0, 1, 0, 1, 1}, {0, 1, 1, 1, 0, 0, 0, 1}, {0, 0, 1, 1, 1, 1, 1, 0, 1}...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int a[60][60] = { {}, {}, {1, 1}, {0, 1, 1}, {1, 0, 0, 1}, {0, 1, 0, 0, 1}, {1, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 0, 0, 1}, {1, 0, 0, 0, 1, 1, 0, 1}, {0, 0, 0, 0, 1, 0, 0, 0, 1}, {1, 0, 0, 1, 0, 0, 0, 0, 1, 1}, {1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1}, {1...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int myTable[50][50] = { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long a[] = {0, 1, 3, 5, 9, 27, 51, 111, 169, 383, 1011, 1779, 385...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long code[55]; int main() { code[2] = 3; code[3] = 5; code[4] = 9; code[5] = 9; code[6] = 3; code[7] = 63; code[8] = 195; code[9] = 275; code[10] = 915; code[11] = 915; code[12] = 2611; code[13] = 3663; code[14] = 4905; code[15] = 8477; co...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int ans[51][6] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 4, 3, 0, 0, 0, 0, 5, 3, 0, 0, 0, 0, 6, 5, 0, 0, 0, 0, 7, 6, 0, 0, 0, 0, 8, 6, 5, 4, 0, 0, 9, 5, 0, 0, 0, 0, 10, 7, 0, 0, 0, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int pp[][51] = { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int N, M; long long biao[55] = {0, 0, 3LL, 5LL, 9LL, 23LL, 54LL, 83LL, 150LL, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k == 2) puts("1 1"); if (k == 3) puts("1 0 1"); if (k == 4) puts("0 0 1 1"); if (k == 5) puts("1 1 1 0 1"); if (k == 6) puts("1 0 0 1 1 1"); if (k == 7) puts("1 1 1 0 1 1 1"); if (k == 8) puts("1 0 0 0 1 1 0 1"); if (k =...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int a; int main() { scanf("%d", &a); if (a == 1) { printf("1 \n"); printf("1\n"); } if (a == 2) { printf("1 1 \n"); printf("0 1\n"); } if (a == 3) { printf("1 0 1 \n"); printf("0 0 1\n"); } if (a == 4) { printf("0 0 1 1 \n"); ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; typedef bool matrix[64][64]; void mul(matrix a, matrix b, matrix c, int n) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { c[i][j] = false; for (int k = 0; k < n; k++) c[i][j] ^= a[i][k] && b[k][j]; } } void pow(matrix a, matrix b, long lon...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) c[i] = (a[i][j] * res[j] + c[i]) & 1; memcpy(res, c,...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); int bitcnt(long long x) { int res = 0; for (; x; x &= x - 1) res++; return res; } void mulModMatr(int n, bool a[51][51], bool b[51][51], bool c[51][51]) { static bool cc[51][51]; memset(cc, 0, sizeof cc); ; for (int i = 0, _n = (n...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxN = 52; int n, t; long long b[100005]; struct mat { bool g[maxN][maxN]; mat operator*(const mat &o) { mat c; for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) { c.g[i][j] = 0; for (int k = 1; k <= n; ++k) c.g[i][j] ^= g...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int main() { string s[100]; s[2] = "1 1"; s[3] = "1 0 1"; s[4] = "1 0 0 1"; s[5] = "0 1 1 1 1"; s[6] = "1 0 0 0 0 1"; s[7] = "1 1 1 1 1 0 1"; s[8] = "0 1 1 0 0 0 1 1"; s[9] = "1 1 1 0 0 1 0 1 1"; s[10] = "1 1 0 1 1 0 0 0 1 1"; s[11] = "1 1 0 0 0 0 1 1 ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; struct mat { int e[51][51]; int h, w; mat() { memset(e, 0, sizeof(e)); h = w = 0; } mat operator*(mat u) const { mat res; res.h = h; res.w = u.w; for (int i = 1; i <= h; i++) { for (int j = 1; j <= u.w; j++) { for (int k = 1; ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 60; using ll = long long; inline ll count(ll x) { for (int i = 32; i; i >>= 1) x ^= x >> i; return x & 1; } int n; struct Arr { ll a[N]; Arr operator+(const Arr &b) const { Arr c; for (int i = 0; i < n; i++) { c.a[i] = 0; for (int j...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int ans[] = {0, 0, 3, 3, 3, 15, 27, 15, 29, 27, 27, 23, 83, 27, 43, 23, 45, 15, 39, 39, 83, 39, 57, 43, 27, 15, 71, 39, 83, 23, 83, 15, 197, 83, 281, 387, 387, 83, 99, 147, 57, 15, 153, 89, 101, 27, 449, 51, 657, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int a[] = {0, 0, 1, 1, 1, 2, 1, 1, 14, 8, 4, 2, 41, 13, 21, 1, 22, 4, 19, 19, 4, 2, 1, 16, 13, 4, 35, 19, 4, 2, 41, 4, 87, 41, 115, 2, 59, 31, 49, 8, 28, 4, 31, 44, 50, 13, 151, 16, 91, 56, 14}, n; int main() { scanf("%d", &n); for (int i = ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
import java.util.*; import java.io.*; import java.math.*; public class Solution { final int[][] data = new int[][] { {}, {0}, {1,0}, {1,0}, {1,0}, {2,0}, {1,0}, {1,0}, {4,3,2,0}, {4,0}, ...
JAVA
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long ans[] = {0LL, 1LL, 3LL, 5LL, 9, 27, 51, 111LL, 169LL, 383LL, 1011LL, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int a[51][51], c[51], f[51][51], n, m, i; long long b[51]; void divide(long long x) { for (long long i = 2; i * i <= x; i++) if (x % i == 0) { b[++m] = ((1ll << n) - 1) / i; while (x % i == 0) x /= i; } if (x > 1) b[++m] = ((1ll << n) - 1) / x; } voi...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const int N = 55; int n, w[N][N]; long long k = 0, s = 1, checklist[110]; bool prim(long long x) { for (int i = 2; i <= int(sqrt(x)); i++) if (x % i == 0) return (false); return (true); } bool get(long long x) { int i, j, k, l, tmp, d[N], temp[N][N], ans[N][N]; for (i = 1; i <= n; i...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int f[49][50] = { {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int Maxn = 49; vector<int> table[Maxn] = { {2, 1, 0}, {3, 1, 0}, {4, 1, 0}, {5, 2, 0}, {6, 1, 0}, {7, 1, 0}, {8, 4, 3, 2, 0}, {9, 7, 4, 2, 0}, {10, 6, 5, 2, 0}, {11, 8, 5, 2, 0}, {12, 7, 4, 3, 0}, {...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int k, P, tail; long long int prime[1000000], chklist[100000], X; struct matrix { int a[51][51]; } matmp, matans, mat, mat0[52]; void find_prime() { int i, j; for (i = 2; (long long int)i * (long long int)i <= X; i++) { if (X % i) continue; for (j = 1; j <= P; j++) if (i % p...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 50; int n; struct Tmtx { bool a[maxn][maxn]; int n; Tmtx() {} Tmtx(int _n, bool x = 0) { int i; n = _n, memset(a, 0, sizeof a); for (i = 0; i < n; ++i) a[i][i] = x; } Tmtx Tpose() const { Tmtx b; register int i, j; for (i...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; typedef int mat[55][55]; int c[55]; vector<long long> vlist; mat g; int n; void mult(mat &res, mat &a, mat &b) { static mat c; memset(c, 0, sizeof c); for (int i = (1); i <= (n); i++) for (int j = (1); j <= (n); j++) for (int k = (1); k <= (n); k++) ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 56; int n; long long len; struct matrix { int m[maxn][maxn]; }; int num; matrix A, B, Tmp, tmp; long long prime[maxn]; int res[maxn]; void cheng(matrix &A, matrix &B, matrix &C) { int i, j, k; memset(&Tmp, 0, sizeof(Tmp)); for (i = 1; i <= n; ++i) ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') positive = 0; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return positive ? x : -x; } const int P = 2...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int kMaxK = 50; int k, c[kMaxK]; long long p; vector<long long> fact; struct Matrix { int v[kMaxK][kMaxK]; void clear() { memset(v, 0, sizeof(v)); } Matrix() { clear(); } } e, f, a, b; Matrix operator*(const Matrix &a, const Matrix &b) { Matrix c; for (int i...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int n; struct Matrix { int a[55][55]; Matrix operator*(const Matrix& b) const { Matrix ret; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) { ret.a[i][j] = 0; for (int k = 0; k < n; ++k) ret.a[i][j] ^= a[i][k] & b.a[k][j]; } ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int N = 60; using ll = long long; inline ll count(ll x) { for (int i = 32; i; i >>= 1) x ^= x >> i; return x & 1; } int n; struct Arr { ll a[N]; Arr operator+(const Arr &b) const { Arr c; for (int i = 0; i < n; i++) { c.a[i] = 0; for (int j...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
import java.io.*; import java.awt.geom.Point2D; import java.text.*; import java.math.*; import java.util.*; public class Main implements Runnable { final String filename = ""; String[] ans = new String[] { "1", "11", "011", "0011", "00101", "000011", "0000011", "00011101", "000010001", "0000001001", "000000001...
JAVA
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; struct matrix { int a[51][51]; }; struct matrix g[70], b, d, s, e; int n, m; int c[60]; long long f[100010]; void multi(matrix &aa, matrix &bb, matrix &cc) { matrix ret; int i, j, k; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) ret.a[i][j] = 0; for (i = 1...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; char p[50][60] = { "11", "110", "1100", "11110", "111001", "1111110", "11111010", "111111101", "1111111100", "11111110100", "111111100100", "1111111111110", "11111111110011", "111111111111110", "1111111111110110", ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[51 * 51]; int n, cnt; typedef bool arr[51][51], arr1[51]; arr a, b, e, tmp[51]; arr1 c, res; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) c[i] = ((a[i][j] * res[j]) + c[i]) & 1; memcpy(res, c, sizeof(res...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long fpm(long long b, long long e, long long m) { long long t = 1; for (; e; e >>= 1, b = b * b % m) e & 1 ? t = t * b % m : 0; return t; } template <class T> inline bool chkmin(T &a, T b) { return a > b ? a = b, true : false; } template <class T> inline bool c...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; struct str { bool a[51][51]; int n; str() : n(0) { memset(this->a, false, sizeof this->a); } str(int _n) : n(_n) { memset(this->a, false, sizeof this->a); } void reset(void) { memset(this->a, 0, sizeof this->a); } void reset(int _n) { memset(this->a, 0, size...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; vector<vector<long long int> > mul(vector<vector<long long int> > a, vector<vector<long long int> > b) { vector<vector<long long int> > res( ((long long int)a.size()), vector<long long int>(((long long int)b[0].size()), 0)); ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
import java.io.*; import java.util.*; public class E { boolean[] get(int k) { ArrayList<Integer> divisors = divisors(k); // System.err.println(((1<<k) - 1)+" "+divisors); for (int i = 0; i < 1000; i++) { boolean[] res = random(k); if (check(res, divisors)) return res; } return null; } final st...
JAVA
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55]; void mul1(arr1 &res, arr &a) { int Tmpy = 0, Tmpy1 = 0; int half = n >> 1; for (int i = 0; i < n; i+...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 51; struct matrix { bool e[maxk][maxk]; int sz; void print() { for (int i = 0, _n = (sz); i < _n; i++) { for (int j = 0, _n = (sz); j < _n; j++) { printf("%d", e[i][j]); } printf("\n"); } printf("\n"); } }; matr...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const long long C[51] = {0, 0, 3LL, 5LL, 9LL, 23LL, 54LL, 83LL, 150LL, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; char S[51][150] = { "", "1", "1 1", "1 0 1", "1 0 0 1", "1 1 1 0 1", "1 0 1 1 0 1", "1 0 1 0 1 0 1", "0 1 1 0 1 0 0 1", "1 1 1 0 1 0 1 0 1", "1 0 0 1 1 1 1 0 0 1", "0 0 0 0 0 1 0 1 1 0 1", "0 0 1 0 0 0 1 1 1 1 0 1", "1...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxk = 51; struct matrix { bool e[maxk][maxk]; int sz; void print() { for (int i = 0, _n = (sz); i < _n; i++) { for (int j = 0, _n = (sz); j < _n; j++) { printf("%d", e[i][j]); } printf("\n"); } printf("\n"); } }; matr...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; void out(vector<int>& v) { for (int i = 0; i < v.size(); ++i) cout << v[i] << " "; cout << endl; } int main() { int n; cin >> n; vector<int> p(n + 1); p.back() = 1; vector<int> c(n); c[0] = 1; if (n == 2) { p[1] = 1; } if (n == 3) { p[1] = 1; ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long n, m, a[1008], b[1008]; int k, tot; long long p[1008]; struct Tmatrix { bool num[55][55]; void clear() { memset(num, 0, sizeof(num)); } void unit() { clear(); for (int i = 1; i <= k; i++) num[i][i] = 1; } Tmatrix operator*(const Tmatrix &t) { ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int c[200], k; long long ans[100]; long long fac[100000]; int cnt; void mult(int a[][100], int b[][100], int c[][100]) { int d[100][100] = {0}; for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { if (a[i][j]) { for (int m = 0; m < k; m++) d[i][m] ^= b[j][m]; ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; inline int nextint() { int res = 0; int neg = 1; char c = 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = '0', neg = -1; while (c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } return neg * res; } string...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int a[] = {0, 0, 1, 1, 1, 2, 1, 1, 14, 8, 4, 2, 41, 13, 21, 1, 22, 4, 19, 19, 4, 2, 1, 16, 13, 4, 35, 19, 4, 2, 41, 4, 87, 41, 115, 2, 59, 31, 49, 8, 28, 4, 31, 44, 50, 13, 151, 16, 91, 56, 14}...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int n, m; int k; bool debug = false; int mat[51][51][51]; long long T, fac[51]; int c[51], a[51], t[51]; void mul(int a[51][51], int b[51][51], int c[51][51]) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { c[i][j] = 0; for (int p = 1; p <= n...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt; typedef bool arr[55][55], arr1[55]; arr a, b, e, tmp[55]; arr1 c, res; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) c[i] = (a[i][j] & res[j]) + c[i] & 1; memcpy(res, c, sizeof(res))...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0; char ch = getchar(); bool positive = 1; for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') positive = 0; for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0'; return positive ? x : -x; } const int P = 2...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 50; int n; struct Matrix { bool num[MAXN][MAXN]; Matrix() { memset(num, 0, sizeof(num)); } Matrix operator*(const Matrix& b) const { Matrix c; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) for (int k = 0; k < n; ++k) c....
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; long long c[51] = {0, 0, 3LL, 5LL, 9LL, 23LL, 54LL, 83LL, 150LL, 500LL, 894LL, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const int fin = 0; const long long C[51] = {0, 0, 3LL, 5LL, 9LL, 23LL, 54LL, 83LL, 150LL, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int a[51][3] = { {-1, -1, -1}, {-1, -1, -1}, {1, -1, -1}, {1, -1, -1}, {1, -1, -1}, {1, 2, 3}, {1, 4, 5}, {2, 3, 4}, {1, 2, 7}, {3, 5, 6}, {2, 3, 8}, {1, 8, 10}, {1, 2, 10}, {3, 5, 8}, {1, 11, 12}, {3, 4, 12}, {10, 12, 15}, {4, 12, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; inline int add(int a, int b) { return a ^ b; } inline int mult(int a, int b) { return a & b; } namespace matrix { template <int N, int M> class matr { public: int dat[N][M]; void init() { memset(dat, 0, sizeof(dat)); } void iden() { init(); for (int i = 0; i ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 52; int Nextint() { char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); int x = 0; while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x; } int A[maxn][maxn], S[maxn], N, lt, B[maxn][maxn], C[ma...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long T, o[50]; int n, k, a[50], c[50], b[50][50], d1[50], d2[50][50]; bool equal(long long m) { memset(a, 0, sizeof a); memset(b, 0, sizeof b); a[k - 1] = 1; for (int i = 0; i < k; ++i) { if (i) b[i][i - 1] = 1; b[i][k - 1] = c[k - 1 - i]; } while (m) { if (m & 1) {...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; inline int powmod(int a, int b) { int tmp = 1; for (; b; b >>= 1) { if (b & 1) tmp = (long long)tmp * a % 1000000007; a = (long long)a * a % 1000000007; } return tmp; } template <class T> inline void R(T &xx) { xx = 0; char ch = getchar(); bool F = 0; ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int ans[] = {0, 0, 1, 1, 1, 2, 1, 1, 14, 8, 4, 2, 41, 13, 21, 1, 22, 4, 19, 19, 4, 2, 1, 16, 13, 4, 35, 19, 4, 2, 41, 4, 87, 41, 115, 2, 59, 31, 49, 8, 28, 4, 31, 44, 50, 13, 151, 16, 91, 56, 14}; int main() { ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int MAXN = 55; int n; long long tr[MAXN]; int top = 0; int a[MAXN]; int mar[MAXN][MAXN][MAXN]; bool Same(long long p) { int tmp[2][MAXN][MAXN]; memset(tmp, 0, sizeof(tmp)); int now = 0; for (int i = 1; i <= n; i++) tmp[now][i][i] = 1; for (int d = 0; d <= n;...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const int t = 50; int f[t][t][t], g[t][t]; long long p[t]; int cnt; void mul(int c[t][t], int a[t][t], int b[t][t], int n) { int d[t][t]; memset(d, 0, sizeof d); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) d[i][k] ^= a[i][j] & b[j][k]; m...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> bool randbit() { static int r = -1; static int c = -1; if (c == -1) { c = 15; r = rand(); } bool x = (r >> c) & 1; c--; return x; } int c[110]; int n; int a[110]; int tmp[110]; int tt[110]; inline void gen() { for (int i = 1; i < n; i++) c[i] = randbit(); c[0] = 1; } i...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int ans[52] = {0, 0, 3, 3, 3, 15, 3, 3, 29, 17, 255, 5, 83, 4095, 43, 3, 63, 15, 63, 63, 1023, 63, 3, 63, 27, 15, 4095, 39, 4095, ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const double PI = 3.1415926535898; const double EPS = 1e-10; using namespace std; string arr[] = { "", "", "1", "2", "3", "3", "5", "6", "4,5,6", "5", "7", "9", "1,4,6", "1,3,4", "1,3,5", "14", "4,...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> const int ans[52] = { 0, 0, 3, 3, 3, 15, 3, 3, 29, 17, 255, 5, 83, 4095, 43, 3, 63, 15, 63, 63, 1023, 63, 3, 63, 27, 15, 4095, 39, 4095, 5, 83, 15, 175, 1048575, 6...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int maxn = 52; int Nextint() { char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); int x = 0; while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x; } int A[maxn][maxn], S[maxn], N, lt, B[maxn][maxn], C[ma...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) c[i] = (a[i][j] * res[j] + c[i]) & 1; m...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55]; void mul1(arr1 &res, arr &a) { memset(c, 0, sizeof(c)); for (int i = 0; i < n; i++) for (int j = 0...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> long long S, d[55 * 55]; int n, cnt, a[55][55], b[55][55], e[55][55], c[55], res[55]; typedef int arr[55][55], arr1[55]; arr tmp[55]; unsigned int tmpx[55], tmpy[55], tmpx1[55], tmpy1[55], Tmpx[55][55], Tmpx1[55][55]; void build(arr a, unsigned int tmpx[55], unsigned int tmpx1[55]) { int ...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; const int kMaxK = 50; int k, c[kMaxK]; long long p; vector<long long> fact; struct Matrix { int v[kMaxK][kMaxK]; void clear() { memset(v, 0, sizeof(v)); } Matrix() { clear(); } } e, f, a, b; Matrix operator*(const Matrix &a, const Matrix &b) { Matrix c; for (int i...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; char dabiao[50][60] = { "11", "110", "1100", "11110", "111001", "1111110", "11111010", "111111101", "1111111100", "11111110100", "111111100100", "1111111111110", "11111111110011", "111111111111110", "11111111111101...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> using namespace std; int k; long long M; vector<long long> D; void mul(long long *c, long long *a, long long *b) { memset(c, 0, k * sizeof(long long)); for (int i(0); i < k; ++i) for (int j(0); j < k; ++j) if (a[i] & 1ll << j) c[i] ^= b[j]; } void mul(long long *a, long long *b) {...
CPP
86_E. Long sequence
A sequence a0, a1, ... is called a recurrent binary sequence, if each term ai (i = 0, 1, ...) is equal to 0 or 1 and there exist coefficients <image> such that an = c1·an - 1 + c2·an - 2 + ... + ck·an - k (mod 2), for all n ≥ k. Assume that not all of ci are zeros. Note that such a sequence can be uniquely recovere...
2
11
#include <bits/stdc++.h> int n, m, a[51], t[51], c[51], b[51][51][51]; long long p[51], N, T; void Mul(int a[51][51], int b[51][51], int c[51][51]) { for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { c[i][j] = 0; for (int k = 1; k <= n; k++) c[i][j] ^= a[i][k] & b[k][j]; } } bool Unit(lo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int n, l, r; long long mod; vector<int> primes; vector<long long> powPrime, modFact[100000 + 1]; long long modPow(long long a, long long pow, long long m) { if (pow == 0) return 1; if (pow & 1) return (a * modPow(a, pow ^ 1, m)) % m; else { long long sqrt = mo...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long N = 100005, K = 30; long long ans, fac[N], inv[N], a[K], num[N][K], n, M, L, R, cnt; long long ksm(long long x, long long y) { long long ans = 1; for (; y; y >>= 1, x = x * x % M) if (y & 1) ans = ans * x % M; return ans; } long long C(long long x,...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const long long maxN = 1e5 + 10, LOG = 20; long long mod, fact[maxN], rev[maxN]; vector<long long> pr; long long power(long long a, long long b) { if (b == 0) return 1; long long res = power(a, b / 2); res *= res, res %= mod; if (b & 1) res *= a, res %= mod; retur...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 100005; int pri[55], mul[55], cnt[55]; int fac[N], inv[N]; int val[N], sum[N]; int n, mod, l, r; void divide() { for (int i = (int)(2); i <= (int)(50000); i++) if (mod % i == 0) { pri[++*pri] = i; mul[*pri] = 1; for (; mod % i == 0; mod...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; inline long long read() { long long x = 0; bool f = 0; char c = getchar(); for (; !isdigit(c); c = getchar()) f ^= !(c - 45); for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; if (f) x = -x; return x; } long long md, b[200005], phi, pr[200005], n, p, l, r...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 7; int n, l, r, p; int tot; long long fac[maxn], inv[maxn], a[maxn], c[maxn][30]; long long qpow(long long x, long long n) { long long res = 1; while (n) { if (n & 1) res = res * x % p; n >>= 1; x = x * x % p; } return res; } void ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int maxn = 100010; long long f[maxn], rev[maxn], P, N, p[20], cnt, num[maxn][20]; inline long long quick_mul(long long a, long long b, long long p) { unsigned long long c = (long double)a / p * b; long long ret = a * b - (unsigned long long)c * p; ret %= p; wh...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, mod, cnt, p[105]; int fac[N], ifac[N], pre[N][20]; int Pow(int x, int k) { int ret = 1; while (k) { if (k & 1) ret = 1ll * ret * x % mod; k >>= 1; x = 1ll * x * x % mod; } return ret; } int C(int n, int m) { if (n < m || m ...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int N = 101010; long long ans, a[N]; int M, n, i, L, R, jj, l, tot, p[N], P[N], w[9]; struct U { long long x, z; U() {} U(long long x, long long z) : x(x), z(z) {} }; void exgcd(long long a, long long b, long long &x, long long &y) { if (!b) { x = 1; y...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool cmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool cmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } int inp() { int x = 0, f = 1; char ch; for (ch = getchar(); !isdigit(ch); ch = getch...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("avx") using namespace std; template <typename T> inline bool cmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <typename T> inline bool cmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } int inp() { i...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; int i, j, k, n, m, p; int a[33], c[100010][33]; int fac[100010], inv[100010]; int l, r, L, R, len, Ans; inline int Pow(int x, int y) { int Ans = 1; for (; y; y >>= 1, x = 1ll * x * x % p) if (y & 1) Ans = 1ll * Ans * x % p; return Ans; } inline void Init() { int...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; using ll = long long; static const ll N = 1e5 + 10; static const ll P = 11; ll n, p, l, r; ll t = 0; vector<ll> prime(P); vector<ll> fac(N); vector<ll> inv(N); vector<ll> val(N); vector<vector<ll>> vp(P, vector<ll>(N)); vector<vector<ll>> po(P, vector<ll>(N)); inline ll mod...
CPP
896_D. Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. <image> However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are ...
2
10
#include <bits/stdc++.h> using namespace std; const int MN = 100010; vector<int> pr, pchk; void Sieve() { pchk = vector<int>(MN, 0); for (int i = 2; i < MN; i++) { if (!pchk[i]) { pr.push_back(i); } for (int j = 0; j < pr.size() && i * pr[j] < MN; j++) { pchk[i * pr[j]] = 1; if (i % pr...
CPP