Submission #11375148


Source Code Expand

#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N =35;
const int mod = 1e9 + 7;
int L, m, k;
ll n;
bool v[N];
struct sq{
	int a[N][N];
	sq() { memset(a, 0, sizeof(a)); }
	sq operator * (const sq &b) const
	{
		int i, j, k;
		sq c;
		for (i = 0; i <= L; i++)
			for (j = 0; j <= L; j++)
				for (k = 0; k <= L; k++)
					c.a[i][j] = (1LL * a[i][k] * b.a[k][j] % mod + c.a[i][j]) % mod;
		return c;
	}
};
sq A, an;
void dfs(int x, int nw, int da)
{
	if (!(x ^ m))
	{
		v[da] = 1;
		int ne = da >> 1;
		A.a[ne][da] = 1;
		if (nw ^ k || da & 1)
			A.a[ne | (1 << (m - 1))][da] = 1;
		return;
	}
	dfs(x + 1, nw, da);
	if (nw < k)
		dfs(x + 1, nw + 1, da | (1 << x));
}
void ksm()
{
	an = A;
	if (!n)
		return;
	for (n--; n; n >>= 1, A = A * A)
		if (n & 1)
			an = an * A;
}
int main()
{
	int i, s = 0;
	scanf("%lld%d%d", &n, &m, &k);
	L = (1 << m) - 1;
	dfs(0, 0, 0);
	ksm();
	for (i = 0; i <= L; i++)
		if (v[i])
			s = (1LL * s + an.a[i][i]) % mod;
	printf("%d", s);
	return 0;
}

Submission Info

Submission Time
Task B - n^p mod m
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 0
Code Size 1077 Byte
Status RE
Exec Time 217 ms
Memory 262272 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:52:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%d%d", &n, &m, &k);
                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status AC
WA × 6
RE × 23
Set Name Test Cases
Sample
All 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
001.txt RE 95 ms 128 KB
002.txt RE 97 ms 128 KB
003.txt RE 97 ms 128 KB
004.txt RE 96 ms 128 KB
005.txt RE 98 ms 128 KB
006.txt RE 107 ms 26752 KB
007.txt RE 117 ms 46976 KB
008.txt RE 112 ms 33024 KB
009.txt WA 27 ms 42624 KB
010.txt WA 16 ms 27776 KB
011.txt RE 215 ms 262272 KB
012.txt RE 215 ms 262272 KB
013.txt RE 216 ms 262272 KB
014.txt RE 216 ms 262272 KB
015.txt RE 217 ms 262272 KB
016.txt RE 217 ms 262272 KB
017.txt RE 216 ms 262272 KB
018.txt RE 216 ms 262272 KB
019.txt RE 216 ms 262272 KB
020.txt RE 217 ms 262272 KB
021.txt WA 0 ms 128 KB
022.txt WA 1 ms 128 KB
023.txt RE 217 ms 262272 KB
024.txt RE 215 ms 262272 KB
025.txt WA 0 ms 128 KB
026.txt WA 1 ms 128 KB
027.txt RE 217 ms 262272 KB
sample_01.txt RE 96 ms 128 KB
sample_02.txt RE 216 ms 262272 KB