This commit is contained in:
HuangHai
2025-10-05 18:33:03 +08:00
parent a6ed9954d6
commit 573c77674e
3 changed files with 160 additions and 25 deletions

View File

@@ -1,31 +1,23 @@
#include <bits/stdc++.h>
using namespace std;
long long n;
int w[1001];
int s[1001];
int main() {
cin >> n;
bool first = true;
for (long long p = 2;p*p<=n;p++){
if (n % p != 0) continue;
int cnt = 0;
while (n % p == 0){
n /= p;
cnt++;
}
if (first){
first = false;
cout << p;
}else{
cout << " * " << p;
}
if (cnt > 1) cout << " ^ " << cnt;
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> w[i];
}
if (n != 1){
if (first){
first = false;
cout << n;
}else{
cout << " * " << n;
}
int ans = 0;
sort(w + 1, w + 1 + n);
int j = 0;
for(int i = 1; i <= n; i++){
j++;
if (j == m+ 1) j = 1;
s[j] += w[i];
ans += s[j];
}
return 0;
cout << ans << endl;
return 0;
}