QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#714028 | #7128. Huge products | hejinming983282 | WA | 0ms | 3668kb | C++23 | 1.4kb | 2024-11-05 21:17:35 | 2024-11-05 21:17:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll a[11]; // a[1] to a[10]
for(int i=1;i<=10;i++) cin >> a[i];
// Check if a2 to a10 are all zero
bool all_zero = true;
for(int i=2;i<=10;i++) {
if(a[i] != 0){
all_zero = false;
break;
}
}
if(all_zero){
// If only 1's are available (or none), the only product is 1
cout << "1";
return 0;
}
// Calculate exponents for each prime
// Prime 2: contributed by 2,4,6,8,10
ll c2 = (a[2] * 1) + (a[4] * 2) + (a[6] * 1) + (a[8] * 3) + (a[10] * 1);
// Prime 3: contributed by 3,6,9
ll c3 = (a[3] * 1) + (a[6] * 1) + (a[9] * 2);
// Prime 5: contributed by 5,10
ll c5 = (a[5] * 1) + (a[10] * 1);
// Prime 7: contributed by 7
ll c7 = a[7] * 1;
// Number of distinct exponents for each prime
// Since the gcd of step sizes for all primes is 1, all exponents from 0 to c are achievable
ll term2 = (c2 + 1) % MOD;
ll term3 = (c3 + 1) % MOD;
ll term5 = (c5 + 1) % MOD;
ll term7 = (c7 + 1) % MOD;
// Calculate the final number of distinct products
ll res = (((term2 * term3) % MOD) * term5) % MOD;
res = (res * term7) % MOD;
cout << res;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
0 1 0 1 0 0 0 1 0 0
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
0 1000000000 100000000 0 0 0 0 0 0 0
output:
400000001
result:
ok 1 number(s): "400000001"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
5 1 1 5 0 0 3 4 4 0
output:
960
result:
ok 1 number(s): "960"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3668kb
input:
0 3 4 0 1 0 2 2 0 2
output:
720
result:
wrong answer 1st numbers differ - expected: '630', found: '720'