QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#520916 | #6669. Mapa | mss | 0 | 0ms | 0kb | C++14 | 2.5kb | 2024-08-15 17:27:39 | 2024-08-15 17:27:40 |
answer
#include <bits/stdc++.h>
#define p pair<ll, ll>
#define x first
#define y second
using namespace std;
using ll = long long;
const int N = 2e5+5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int BAZA = 69313;
int n;
int t;
p a[N];
vector<ll> k;
vector<ll> v;
int m, q;
string s;
ll add(ll x, ll y){
if(x + y < 0) return x + y + MOD;
else return (x + y) % MOD;
}
ll mul(ll x, ll y){
return (x * y) % MOD;
}
ll pot(ll baza, ll exp){
if(exp == 0) return 1;
ll pol = pot(baza, exp / 2);
if(exp % 2) return mul(baza, mul(pol, pol));
return mul(pol, pol);
}
ll _div(ll x, ll y){
return mul(x, pot(y, MOD - 2));
}
void mulk(ll tk){
v.insert(v.begin(), 0);
for(int i = 0; i < v.size() - 1; i++){
cout << "x^" << i << ": ";
cout << v[i] << " + " << v[i + 1] << " * " << -tk << " = " << add(v[i], mul(v[i + 1], -tk)) << "\n";
v[i] = add(v[i], mul(v[i + 1], -tk));
}
}
void encode(){
for(int i = 0; i < n; i++){
cin >> a[i].x >> a[i].y;
}
for(int i = 0; i< n; i++){
k.push_back(0);
}
for(int i = 0; i< n; i++){
ll konst = 1;
int ind = 0;
if(i != n - 1) ind = i + 1;
v.clear();
v.push_back(-a[ind].x);
v.push_back(1);
cout << "v: \n";
cout << 1 << " " << -a[ind].x << "\n";
for(int j = 0; j < n; j++){
if(i == j || j == ind) continue;
mulk(a[j].x);
for(int l = 0; l < v.size(); l++){
cout << v[l] << " ";
}
cout << "\n";
}
cout << "-------\n";
for(int j = 0; j < n; j++){
if(i != j){
konst = mul(add(a[i].x, - a[j].x), konst);
}
}
cout << "here\n";
konst = _div(a[i].y, konst);
cout << "here\n";
for(int j = 0; j < v.size(); j++){
k[j] = add(k[j], mul(v[j], konst));
}
cout << "here\n";
}
for(int i = 0; i< n; i++){
cout << k[i] << "\n";
}
int uk = 0;
cout << n * 30 << "\n";
for(int i = 0; i< n; i++){
for(int j = 0; j< 30; j++){
bool b = k[i] & (1 << j);
cout << b;
}
}
}
ll calc(ll x){
ll r = 0;
for(int i = 0; i < n; i++){
r = add(r, mul(k[i], pot(x, i)));
}
return r;
}
void decode(){
cin >> q >> m;
cin >> s;
for(int i = 0; i<m / 30; i++){
int tc = 1;
int br = 0;
for(int j = 0; j < 30; j++){
bool b = s[i * 30 + j] - '0';
br += b * tc;
tc *= 2;
}
k.push_back(br);
}
for(int i = 0; i < q; i++){
int b;
cin >> b;
cout << calc(b) << "\n";
}
}
int main(){
//ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> t;
cin >> n;
if(t == 1) encode();
else decode();
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:
v: 1 -269613430 x^0: 0 + -269613430 * -700489871 = 478537205 x^1: -269613430 + 1 * -700489871 = 29896706 478537205 29896706 1 x^0: 0 + 478537205 * -151890319 = 787977788 x^1: 478537205 + 29896706 * -151890319 = 298935131 x^2: 29896706 + 1 * -151890319 = 878006394 787977788 298935131 878006394 1 x...
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...