QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519812#6669. MapaNikoBaotic0 5ms3576kbC++142.4kb2024-08-15 02:14:372024-08-15 02:14:37

Judging History

你现在查看的是最新测评结果

  • [2024-08-15 02:14:37]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:3576kb
  • [2024-08-15 02:14:37]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

#define all(x) x.begin(), x.end()
#define sz(x) ((int) ((x).size()))
#define pb push_back
#define F first
#define S second
#define FIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;

ll potM(ll x, ll k) { if (k == 0) return 1; ll a = potM(x, k / 2); if (k % 2 == 0) { return (a * a) % MOD; } else { return ((a * a) % MOD * x) % MOD; }}
ll addM(ll a, ll b) { return a + b >= MOD ? a + b - MOD : a + b; }
ll subM(ll a, ll b) { return addM(a, MOD-b); }
ll mulM(ll a, ll b) { return a * b % MOD; }
ll divM(ll a, ll b) { return mulM(a, potM(b, MOD - 2)); }

int n;
vector<pii> t;
vector<ll> pol;
vector<ll> k;

void mul(int x) {
	vector<ll> mp;

	for (int i = 0; i < sz(pol); i++) {
		mp.pb(mulM(pol[i], MOD-x));
	}

	for (int i = 1; i < sz(mp); i++) {
		pol[i - 1] = addM(pol[i - 1], mp[i]);
	}

	pol.insert(pol.begin(), mp[0]);
}

void calcPol() {
	pol.clear();
	pol.pb(1);

	for (int i = 0; i < n - 1; i++) {
		mul(t[i].F);
	}

	ll d = 1;

	for (int i = 0; i < n - 1; i++) {
		d = mulM(d, subM(t[n - 1].F, t[i].F));
	}

	for (int i = 0; i < n; i++) {
		pol[i] = divM(mulM(t[n - 1].S, pol[i]), d);
	}
}

void comp() {
	cin >> n;
       cout << "HELLO" << endl;

	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		
		t.pb({x, y});
	}

	k.resize(n);

	for (int i = 0; i < n; i++) {
		calcPol();

		for (int j = 0; j < n; j++) {
			k[j] = addM(pol[j], k[j]);
		}

		t.insert(t.begin(), t[n - 1]);
		t.erase(prev(t.end()));
	}

	string s;
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 30; j++) {
			if (k[i] & (1 << j)) {
				s.pb('1');
			} else {
				s.pb('0');
			}
		}
	}

	cout << sz(s) << endl;
	cout << s << endl;
}

int q, b;
string s;

void read() {
	cin >> n >> q >> b;

	cin >> s;

	for (int i = 0; i < n; i++) {
		ll cur = 0;
		
		for (int j = 0; j < 30; j++) {
			if (s[i * 30 + j] == '1') {
				cur |= 1 << j;
			}
		}

		k.pb(cur);
	}

	for (int i = 0; i < q; i++) {
		ll sum = 0;
		ll x;
		cin >> x;

		for (int j = 0; j < n; j++) {
			sum = addM(sum, mulM(potM(x, j), k[j]));
		}	
	
		cout << sum << endl;
	}
}

int main() {
	FIO;
	int m;
	cin >> m;

	if (m == 1) {
		comp();
	} else {
		read();
	}

	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: 5ms = 4ms + 1ms
memory: 3576kb,3552kb

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:

HELLO
3000
1010001011000001001110110011100001011110110001101101001000110001110110101011111100011100101100100011001000111010010100001101011101001111001010110110110100000011110111100010111100010011100111110101100010110011000001101001111111110101100100101010001000110101001110101010100011011110100001100...

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:

32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32
32

result:

wrong answer wrong answer on query #1: read 32 but expected 310305144