結果
| 問題 | No.995 タピオカオイシクナーレ |
| コンテスト | |
| ユーザー |
renjyaku_int
|
| 提出日時 | 2020-03-09 16:30:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,557 bytes |
| コンパイル時間 | 1,629 ms |
| コンパイル使用メモリ | 170,388 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-08 04:11:00 |
| 合計ジャッジ時間 | 3,397 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | WA * 23 |
ソースコード
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int mod = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) \
cout << #v << ":"; \
for (auto x : v) \
{ \
cout << x << ' '; \
} \
cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
if (a < b)
{
a = b;
return 1;
}
return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
if (b < a)
{
a = b;
return 1;
}
return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m,k;
ll p,q;
vector<ll> b;
struct matrix{
ll a[70][70];
matrix(){
for (ll i = 0; i < 2; i++)
{
for(ll j=0;j<2;j++){
a[i][j]=0;
}
}
}
};
matrix mult(matrix a, matrix b){
matrix c;
for(ll i=0;i<2;i++){
for(ll j=0;j<2;j++){
for(ll k=0;k<2;k++)
c.a[i][j]=(c.a[i][j]+(a.a[i][k]*b.a[k][j])%mod)%mod;
}
}
return c;
}
matrix binpow(matrix a, ll b){
matrix res;
for(ll i=0;i<2;i++)res.a[i][i]=1;
while(b){
if(b&1)
res=mult(res,a);
b>>=1;
a=mult(a,a);
}
return res;
}
long long modinv(long long a, long long m) {
long long b = m, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
u %= m;
if (u < 0) u += m;
return u;
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n>>m>>k>>p>>q;
for (int i = 0; i < n; i++)
{
ll temp;
cin >> temp;
b.push_back(temp);
}
ll drink_sum=0;
rep(i,m){
drink_sum+=b[i];
}
ll kit_sum=0;
for(int i=m;i<n;i++){
kit_sum+=b[i];
}
matrix s;
ll temp=modinv(q,mod);
s.a[0][0]=(q-p)*temp;
s.a[0][1]=p*temp;
s.a[1][0]=p*temp;
s.a[1][1]=(q-p)*temp;
ll ans=0;
binpow(s,k);
ans+=s.a[0][0]*drink_sum;
ans%=mod;
ans+=s.a[0][1]*kit_sum;
ans%=mod;
cout << ans << "\n";
}
renjyaku_int