QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712693 | #8332. Two in One | CCSU_YZT# | WA | 1ms | 3556kb | C++20 | 1.6kb | 2024-11-05 16:41:52 | 2024-11-05 16:41:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
bool isprime(int n) {
if (n <= 1)
return false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0)
return false;
}
return true;
}
int findPrime(int n) {
while (!isprime(n)) n++;
return n;
}
void solve() {
ll n, k;
cin>>n>>k;
vector<ll> a(n+1);
vector<string> s(n+1);
for (int i = 1; i <= n; i++) {
cin>>s[i];
}
int M = 9e8, M1 = 1e8;
int mod = findPrime(rng() % M + M1);
set<ll> st;
ll ans = 0;
for (int t = 0; t <= 3; t++) {
ll target = 0;
for (int i = 1; i <= k; i++) {
target = target * 10 + 9;
target %= mod;
}
target = target * t % mod;
st.insert(target);
}
for (int i = 1; i <= n; i++) {
ll val = 0;
for (auto ch : s[i]) {
val = val * 10 % mod + ch - '0';
val %= mod;
}
a[i] = val;
}
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j++) {
for (int l = j; l <= n; l++) {
if (st.count((a[i] + a[j] + a[l]) % mod)) {
ans++;
}
}
}
}
cout<<ans<<'\n';
}
int main() {
if (ifstream("test.in")) {
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
}
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3556kb
input:
1 7 1 2 3 4 3 2 1
output:
0
result:
wrong answer 1st numbers differ - expected: '3', found: '0'