A. Strange Partition Problem - A - Codeforces 2022-12-15 14:00:52
#include <bits/stdc++.h> #define int long long const int N=100010; using namespace std; int a[N]; signed main() { int t; cin>>t; while(t--) { int n,k; cin>>n>>k; double sum = 0; double sum1 = 0; for(int i=1;i<=n;i++) { cin>>a[i]; sum += a[i] * 1.0; sum1 += ceil((double)a[i] / k); } printf("%.0lf %.0lf",(double)ceil(sum / k),sum1); printf("\n"); } return 0; }
B. Strange List
Problem - B - Codeforces 2022-12-15 14:27:52标签:Round.694,ABC,15,idx,int,sum,codeforces,long,cin From: https://www.cnblogs.com/codeforceshobby/p/16984875.html#include <bits/stdc++.h> #define int long long const int N=100010; using namespace std; int a[N]; signed main() { int t; cin>>t; while(t--) { int n,k; cin>>n>>k; int sum = 0; int idx = 1; int res = 0x3f3f3f3f; for(int i=0;i<n;i++) { int cnt = 0; cin>>a[i]; for(int j = k;;j *= k) { if(a[i] % j == 0) { cnt++; } else { break; } } if(res > cnt) { res = cnt; idx = i; } } for(int i=0;i<idx;i++) { sum += (res + 2) * a[i]; } for(int i=idx;i<n;i++) { sum += (res + 1) * a[i]; } cout<<sum<<"\n"; } return 0; }C. Strange Birthday Party
Problem - C - Codeforces 2022-12-15 15:23:50
#include <bits/stdc++.h> #define int long long const int N=1000010; using namespace std; int a[N]; int b[N]; void solve() { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=m;i++) { cin>>b[i]; } sort(a+1,a+1+n); int ans = 0; int idx = 1; for(int i = n;i >= 1;i -- ) { if(a[i] > idx) { ans += b[idx ++]; } else { ans += b[a[i]]; } } cout<<ans<<"\n"; } signed main() { int t; cin>>t; while(t--) { solve(); } return 0; }