QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#520792 | #6669. Mapa | vitosevski | 0 | 0ms | 0kb | C++17 | 2.1kb | 2024-08-15 15:50:11 | 2024-08-15 15:50:11 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define F first
#define S second
#define sz(x) int(x.size())
const ll MOD=1e9+7;
ll pot(ll n, ll k) {
ll ret=1;
while(k) {
if(k%2) {
ret=ret*n%MOD;
}
n=n*n%MOD;
k/=2;
}
return ret;
}
ll inv(ll x) {
return pot(x, MOD-2);
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
cin >> T;
if(T==1) {
int n;
cin >> n;
// vector<pair<int, int>> x(n);
vector<ll> x(n), y(n);
for(int i=0; i<n; i++) {
cin >> x[i] >> y[i];
}
vector<ll> ko(n);
for(int i=0; i<n; i++) {
// prolazi kroz y=0 za sve osin i
// cout << "i=" << i << '\n';
vector<ll> t(n);
ll mul=y[i];
// cout << "mul=" << mul << '\n';
if(i==0) {
t[0]=(-x[1]+MOD)%MOD;
mul=mul*inv(x[0]-x[1]+MOD)%MOD;
}
else {
t[0]=(-x[0]+MOD)%MOD;
mul=mul*inv((x[i]-x[0]+MOD)%MOD)%MOD;
// if(i==1) cout << "mul2=" << mul << '\n';
}
t[1]=1;
for(int j=1+(i==0); j<n; j++) {
if(i!=j) {
vector<ll> tt(n);
for(int k=1; k<n; k++) {
tt[k]=t[k-1];
}
for(int k=0; k<n; k++) {
tt[k]=(tt[k]+(-x[j]+MOD)%MOD*t[k]%MOD)%MOD;
}
t=tt;
mul=mul*inv((x[i]-x[j]+MOD)%MOD)%MOD;
}
}
// cout << "mul=" << mul << '\n';
for(int j=0; j<n; j++) {
ll koef=mul*(t[j])%MOD;
// cout << koef << ' ';
ko[j]=(ko[j]+koef)%MOD;
}
// cout << '\n';
}
// cout << '\n';
// for(int i=0; i<n; i++) {
// cout << "x^" << i << ": " << ko[i] << '\n';
// }
string s=string(n*30, '0');
for(int i=0; i<n; i++) {
for(int j=0; j<30; j++) {
s[30*i+j]=char('0'+ ( (ko[i]&(1LL<<j))!=0 ) );
}
}
cout << s << '\n';
}
else {
int n, q, k;
cin >> n >> q >> k;
string s;
cin >> s;
vector<ll> ko(n);
for(int i=0; i<n; i++) {
for(int j=0; j<30; j++) {
ko[i]+=(1LL<<j)*(s[i*30+j]-'0');
}
}
while(q--) {
ll x;
cin >> x;
ll rj=0;
for(int i=0; i<n; i++) {
rj=(rj+ko[i]*pot(x, i)%MOD)%MOD;
}
cout << rj << '\n';
}
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
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:
101000101100000100111011001110000101111011000110110100100011000111011010101111110001110010110010001100100011101001010000110101110100111100101011011011010000001111011110001011110001001110011111010110001011001100000110100111111111010110010010101000100011010100111010101010001101111010000110011010001100...
input:
Invalid Output on Phase 1