版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/82813944
前言
这周居然考两道数学,反正是我的弱项。然后第一题考试的时候zz了竟然忘了怎么二分
成绩
只放
正题
遨游【二分答案 】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82812117
今天你 了吗 【康托展开 高精度 二分答案 树状数组】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82813059
简单数学题【约数 换元法】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82813365
T1-70分代码
#include<cstdio>
#include<algorithm>
#include<queue>
#define M 100010
#define N 50010
using namespace std;
struct line{
int from,to;
double w;
int next;
}a[M*2];
struct node{
double l,r;
}f[N];
queue<int> q;
int n,m,x,y,w,tot,ans;
int ls[N],mark[N],h[N],s,t;
bool v[N];
void addl(int x,int y,double w)
{
a[++tot]=(line){x,y,w,ls[x]};ls[x]=tot;
a[++tot]=(line){y,x,w,ls[y]};ls[y]=tot;
}
void spfa()
{
q.push(s);v[s]=true;
for(int i=1;i<=ans;i++)
f[i]=(node){0,2147483647};
f[s]=(node){2147483647,0};
while(!q.empty())
{
int x=q.front();
q.pop();
for(int i=ls[x];i;i=a[i].next)
{
int y=a[i].to;
if(min(f[x].l,a[i].w)>f[y].l||
(min(f[x].l,a[i].w)==f[y].l&&
max(f[x].r,a[i].w)<f[y].r))
{
f[y]=(node){min(f[x].l,a[i].w),max(f[x].r,a[i].w)};
if(!v[y])
{
v[y]=true;
q.push(y);
}
}
}
v[x]=false;
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++)
{
scanf("%d%d%d",&x,&y,&w);
addl(x,y,w);
}
for(int i=1;i<=n;i++)
{
scanf("%d",&t);
ans+=t;
for(int j=1;j<=t;j++)
{
scanf("%d",&x);
mark[x]=i;
}
}
for(int i=1;i<=n;i++)
scanf("%d",&h[i]);
for(int i=1;i<=tot;i++)
{
x=mark[a[i].from];y=mark[a[i].to];
a[i].w*=(h[x]+h[y])/2.0/100.0;
}
scanf("%d%d",&s,&t);
spfa();
double R=f[t].r;
if(R-(int)R>0) R++;
printf("%d %d\n",(int)f[t].l,(int)R);
}
T2-60分代码
#include<cstdio>
using namespace std;
long long n,k,tot,nI,a[19];
int main()
{
scanf("%lld%lld",&n,&k);nI=1;
for(int i=1;i<n;i++)
nI=nI*i;
for(int i=1;i<=n;i++)
a[i]=i;
tot=n;
for(int i=1;i<=n;i++)
{
int wz=(k-1)/nI+1;
printf("%lld ",a[wz]);
if(i==n) break;
for(int j=wz;j<tot;j++)
a[j]=a[j+1];
k=(k-1)%nI+1;
tot--;
nI/=tot;
}
}
尾声
明天见