QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#119240 | #6669. Mapa | He_Ren# | 0 | 1ms | 3800kb | C++17 | 2.3kb | 2023-07-05 08:41:17 | 2024-05-31 19:04:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 100 + 5;
const int mod = 1e9 + 7;
inline void add_mod(int &a,int b){ a+=b; if(a>=mod) a-=mod;}
inline ll pw(ll a,ll b)
{
ll res = 1;
while(b)
{
if(b&1) res=res*a%mod;
a=a*a%mod; b>>=1;
}
return res;
}
const int MAXF = MAXN * 2;
ll fac[MAXF], inv[MAXF];
inline ll C(int n,int m){ return n<0||m<0||n<m? 0: fac[n] * inv[m] %mod * inv[n-m] %mod;}
namespace P1
{
const int MAXN = 100 + 5;
void solve(void)
{
int n;
scanf("%d",&n);
vector<pii> p(n);
for(auto &t: p)
scanf("%d%d",&t.first,&t.second);
vector<int> ans(n);
vector<int> a(n+1);
a[0] = 1;
for(auto t: p)
{
for(int i=n; i>=1; --i)
a[i] = ((ll)a[i] * (mod - t.first) + a[i-1]) %mod;
a[0] = (ll)a[0] * (mod - t.first) %mod;
}
for(int k=0; k<n; ++k)
{
auto b = a;
for(int i=n; i>=1; --i)
b[i-1] = (b[i-1] - (ll)b[i] * (mod - p[k].first) %mod + mod) %mod;
ll coef = 1;
for(int i=0; i<n; ++i) if(i != k)
coef = coef * (p[k].first - p[i].first + mod) %mod;
coef = pw(coef, mod - 2) * p[k].second %mod;
for(int i=1; i<=n; ++i)
add_mod(ans[i-1], b[i] * coef %mod);
}
printf("ans: ");
for(auto t: ans)
printf("%d ",t);
printf("\n");
printf("%d\n",n * 30);
for(int i=0; i<n; ++i)
{
for(int j=0; j<30; ++j)
printf("%d",(ans[i] >> j) & 1);
}
}
}
namespace P2
{
const int MAXD = 3e3 + 5;
char s[MAXD];
void solve(void)
{
int n,Q,d;
scanf("%d%d%d%s",&n,&Q,&d,s);
vector<int> a;
for(int i=0; i<n; ++i)
{
int x = 0;
for(int j=0; j<30; ++j)
x |= (s[i * 30 + j] - '0') << j;
a.emplace_back(x);
}
while(Q--)
{
int x;
scanf("%d",&x);
int ans = 0, cur = 1;
for(auto t: a)
{
ans = (ans + (ll)cur * t) %mod;
cur = (ll)cur * x %mod;
}
printf("%d\n",ans);
}
}
}
int main(void)
{
fac[0] = 1;
for(int i=1; i<MAXF; ++i)
fac[i] = fac[i-1] * i %mod;
inv[MAXF-1] = pw(fac[MAXF-1], mod-2);
for(int i=MAXF-2; i>=0; --i)
inv[i] = inv[i+1] * (i+1) %mod;
int T;
scanf("%d",&T);
if(T == 1) P1 :: solve();
else P2 :: solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms = 1ms + 0ms
memory: 3800kb,3800kb
input:
1 100 495528311 963488152 269613430 443544124 700489871 792354118 151890319 506569919 180452297 13229948 684464994 543841485 978085128 903812192 238355172 441140842 28061035 783291471 530823766 718942732 936853023 439421263 201361623 226633955 304644844 778868118 864860135 461524170 88300500 6959354...
output:
ans: 484213573 825069032 328193464 43455251 919925483 600960770 215068572 309067352 358394949 207193580 354343266 438842079 704673867 168777911 698575713 491325171 725911543 120595485 165054135 779180084 583956952 513557139 658794796 974502200 689443614 544059098 894541844 270197193 237290696 681253...
input:
2 100 79 0 76056186 748668825 977827900 978085128 116036067 867988891 936853023 382851074 572126679 923962179 896550946 684464994 873686539 38704825 864860135 275947064 317677889 151890319 408905047 491275816 521631260 85278475 216446252 676199581 593919557 298889276 937180891 238355172 205533698 3...
output:
-471561276 -471565504 -948751573 -558902919 -476553205 -566947217 -47677278 -229589945 -349715302 -505387680 -483549568 -839385319 -897524049 -290925771 -505419096 -686952439 -717029441 -43902667 -101215768 -245166242 -98706155 -395686341 -275852210 -161927277 -664368432 -984249150 -689676145 -59649...
result:
wrong answer wrong answer on query #1: read -471561276 but expected 310305144