Submission #1870693


Source Code Expand

#include <cstdio>
#define N 100005
using namespace std;
typedef long long ll;
ll n, m, M=1e9+7, v[N], fac[N]={1}, inv[N];
ll pow(ll p, ll q) {
	ll ret=1;
	for(; q; q>>=1, p = p*p%M) if(q&1) ret = ret*p%M;
	return ret;
}
ll C(ll p, ll q) {return p<q ? 0 : fac[p] * inv[q]%M * inv[p-q]%M;}

int main() {
	ll i, t;
	scanf("%d", &n);
	for(i=1; i<=n+1; i++) {
		scanf("%d", &t);
		v[t] ? m = v[t]+n-i : v[t] = i;
	}
	for(i=1; i<=n+1; i++) fac[i] = i * fac[i-1] % M;
	inv[n+1] = pow(fac[n+1], M-2);
	for(i=n; i>=0; i--) inv[i] = (i+1) * inv[i+1] % M;
	for(i=1; i<=n+1; i++) printf("%d\n",(C(n+1,i) - C(m,i-1) + M) % M);
	return 0;
}

Submission Info

Submission Time
Task D - 11
User t1234
Language C++14 (GCC 5.4.1)
Score 600
Code Size 650 Byte
Status AC
Exec Time 31 ms
Memory 3456 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:16: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
  scanf("%d", &n);
                ^
./Main.cpp:17:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll* {aka long long int*}’ [-Wformat=]
   scanf("%d", &t);
                 ^
./Main.cpp:23:67: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll {aka long long int}’ [-Wformat=]
  for(i=1; i<=n+1; i++) printf("%d\n",(C(n+1,i) - C(m,i-1) + M) % M);
                                                                   ^
./Main.cpp:15:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t);
                  ...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 10
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All 1.txt, mx.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 30 ms 3456 KB
mx.txt AC 31 ms 3456 KB
rnd_0.txt AC 24 ms 2816 KB
rnd_1.txt AC 20 ms 2560 KB
rnd_2.txt AC 6 ms 768 KB
rnd_3.txt AC 5 ms 768 KB
rnd_4.txt AC 9 ms 1152 KB
sample1.txt AC 1 ms 128 KB
sample2.txt AC 0 ms 128 KB
sample3.txt AC 1 ms 128 KB