Submission #1493934


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}

ll mul(ll a, ll b) { return a * b % MOD; }
ll div(ll a, ll b) { return a * mod_pow(b, MOD - 2, MOD) % MOD; }
ll sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll add(ll a, ll b) { return (a + b) % MOD; }

int N, T;
int y[112345];

int main() {
	cin >> N;
	REP(i, N + 1) scanf("%d", y + i);
	cin >> T;
	
	assert(N <= 3000);
	
	if (N >= T) {
		cout << y[T] << endl;
		return 0;
	}
	
	ll sp = 1;
	REP(i, N + 1) sp = mul(sp, sub(T, i));
	
	ll ans = 0;
	REP(i, N + 1) {
		ll now = mul(y[i], div(sp, sub(T, i)));
		
		ll f = 1;
		REP(j, N + 1) if (i != j) f = mul(f, sub(i, j));
		
		ans = add(ans, div(now, f));
	}
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

Submission Time
Task D - 見たことのない多項式
User tkmst201
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1528 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:53:39: error: call of overloaded ‘div(ll&, ll)’ is ambiguous
   ll now = mul(y[i], div(sp, sub(T, i)));
                                       ^
In file included from /usr/include/c++/5/cstdlib:72:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:47,
                 from ./Main.cpp:1:
/usr/include/stdlib.h:789:14: note: candidate: div_t div(int, int)
 extern div_t div (int __numer, int __denom)
              ^
./Main.cpp:29:4: note: candidate: ll div(ll, ll)
 ll div(ll a, ll b) { return a * mod_pow(b, MOD - 2, MOD) % MOD; }
    ^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:47:0,
                 from ./Main.cpp:1:
/usr/include/c++/5/cstdlib:227:3: note: candidate: lldiv_t __gnu_cxx::div(long long int, long long int)
   div(long long __n, long long __d)
   ^
/usr/include/c++/5/cstdlib:169:3: note: candidate: ldiv_t std::div(long int, long int)
   div(long __i, long __j) { return ldiv(__i, __j); }
   ^
./Mai...