多校第五场题解 DEFI
D
这是一个环 每个点跑一遍lis找到最大 n-max就是答案
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int const N=505;
int n,dp[N],a[N],ans,ins;
int main()
{
ios::sync_with_stdio(false);
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i];
}
for(int i = 0;i < n;i ++)
{
memset(dp, 0, sizeof(dp));
for(int j = 1;j <= n;j ++)
{
dp[j] = 1;
for(int k = 1;k < j;k ++)
{
if(a[(i + j) % n + 1] > a[(i + k) % n + 1]) dp[j] = max(dp[j], dp[k] + 1);
}
ins = max(ins, dp[j]);
}
ans = max(ans, ins);
}
cout<<n-ans<<endl;
return 0;
}
E
这是我们队的黄大佬用java写的 看伪代码找最小循环节
import java.util.*;
import java.math.BigInteger;
public class Main
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] a = new int[n+1];
int[] vis = new int[n+1];
BigInteger c = new BigInteger("1");
BigInteger l = new BigInteger("1");
for(int i=1;i<=n;++i)a[i] = s.nextInt();
for(int i=1;i<=n;++i)
{
if(vis[i] != 0)continue;
int x = a[i];
BigInteger tot = new BigInteger("0");
do
{
vis[x] = tot.intValue();
x = a[x];
tot = tot.add(l);
}
while(vis[x] == 0&&x != a[i]);
if(vis[x] != 0)tot.add(new BigInteger(String.valueOf(vis[x])));
c = c.multiply(tot).divide(c.gcd(tot));
}
System.out.println(c);
}
}F
简单的模拟 看懂题意就行
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int nextInt()
{
char c = getchar();
int x = 0,fh = 0;
while(c < '0' || c > '9'){fh |= c == '-';c = getchar();}
while(c >= '0' && c <= '9'){x = (x << 1) + (x << 3) + (c ^ 48);c = getchar();}
return fh?-x:x;
}
signed main()
{
int n = nextInt();
int a[101],maxa = 0;
for(int i=1;i<=n;++i)maxa = max(maxa,a[i] = nextInt());
for(int i=1;i<=n;++i)
{
int t = ceil(50.0*a[i]/maxa);
cout<<'+';for(int i=1;i<=t;++i)cout<<"-";cout<<'+'<<endl;
cout<<'|';
if(a[i] == maxa)
{
for(int i=1;i<=t-1;++i)cout<<' ';
cout<<'*';
}
else
for(int i=1;i<=t;++i)cout<<' ';
cout<<'|'<<a[i]<<endl;
cout<<'+';for(int i=1;i<=t;++i)cout<<"-";cout<<'+'<<endl;
}
return 0;
}I
在无穷大的平面上 每个特殊点必定会对4个基地点产生贡献 有两种特殊点
所以答案是2/3
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
int main()
{
ios::sync_with_stdio(false);
double ans=2.0/3;
printf("%.6f",ans);
return 0;
}
具体看代码理解
每日一题题解 文章被收录于专栏
每日一题题解的汇集


查看8道真题和解析