C

题解

#include <bits/stdc++.h>
#define N 10
using namespace std;
typedef long long ll;

ll arr[N];int n;
ll cal(int tem) {
ll res = 0;
for (int i = 0; i < n; i++) {
if ((tem >> i) & 1)
res += arr[i];
}
return res;
}

bool Judge(ll a, ll b, ll c) {
if (a + b <= c || b + c <= a || a + c <= b)
return 1;
return 0;
}

int main() {
scanf("%d", &n);
double ans = -1;
for (int i = 0; i < n; i++) {
scanf("%lld", arr + i);
}
for (int i = 0; i < (1 << n); i++) {
ll A = cal(i);
for (int j = 0; j < (1 << n); j++) {
if (i & j)
continue;
ll B = cal(j);
for (int k = 0; k < (1 << n); k++) {
if (i & k || j & k) {
continue;
}
ll C = cal(k);
if (Judge(A, B, C))
continue;
double p = (A + B + C) / 2.0;
ans = max(ans, sqrt(p * (p - A) * (p - B) * (p - C)));
}
}
}
if (ans < 0)
printf("-1\n");
else
printf("%.1f\n", ans);
// system("pause");
return 0;
}

D

https://ac.nowcoder.com/acm/contest/11220/D

题解

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
int n;scanf("%d",&n);
ll sum=1ll*(n+1)*n/2;
ll cnt=0;
for(int i=0;i<n;i++){
int num;scanf("%d",&num);
if(num&1){
sum-=1ll*(cnt+1)*cnt/2;
cnt=0;
}else{
cnt++;
}
}
sum-=1ll*(cnt+1)*cnt/2;
printf("%lld\n",sum);
// system("pause");
return 0;
}

E

"满意的集合" 定义：选出的数存在一种排列方式，其拼接起来后表示的十进制整数，能被$3$整除，例如集合 $\left\{3,3,6\right\}$(包含了 $2$个数字$3$,$1$个数字$6$ )，可以有排列$\left\{6,3,3\right\}$代表十进制下的整数 633，能被 3 整除。

题解

#include <bits/stdc++.h>
#define ll long long
const int N=20,mod=1e9+7;
int cnt[N];
ll dp[N][3];
int main() {
for (int i=1; i<=9; i++) scanf("%d",&cnt[i]);
dp[0][0]=1;
for (int i=1; i<=9; i++) {
int mod1=1*i%3,mod2=2*i%3,mod3=3*i%3;
ll sum1=(cnt[i]+2)/3,sum2=(cnt[i]+1)/3,sum3=cnt[i]/3+1;
for (int MOD=0; MOD<3; MOD++) {
dp[i][(mod1+MOD)%3]+=sum1*dp[i-1][MOD];
dp[i][(mod2+MOD)%3]+=sum2*dp[i-1][MOD];
dp[i][(mod3+MOD)%3]+=sum3*dp[i-1][MOD];
dp[i][(mod1+MOD)%3]%=mod;
dp[i][(mod2+MOD)%3]%=mod;
dp[i][(mod3+MOD)%3]%=mod;
}
}
printf("%lld\n",dp[9][0]);
return 0;
}