预计分数:30+30+0=60

实际分数:30+30+10=70

稳有个毛线用,,又拿不出成绩来,,

T1

https://www.luogu.org/problem/show?pid=T15626

一开始掉进了数列的坑里就傻乎乎的没出来过

样例给了个3 5 ,推着推着就感觉是斐波那契数列,GG

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<ctime>
#include<cstdlib>
#define LL long long
using namespace std;
const LL MAXN=1e6;
const LL INF=0x7ffff;
inline LL read()
{
char c=getchar();LL flag=,x=;
while(c<''||c>'') {if(c=='-') flag=-;c=getchar();}
while(c>=''&&c<='') x=x*+c-,c=getchar();return x*flag;
}
LL f[MAXN];
LL ans=;
map<LL,bool>vis;
LL gcd(LL a,LL b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
// freopen("seq.in","r",stdin);
// freopen("seq.out","w",stdout);
LL a=read(),b=read();
if(a==b)
{
printf("");
return ;
}
LL g=gcd(a,b);
a/=g,b/=g;
f[]=a,f[]=b;f[]=abs(b-a);vis[f[]]=;vis[f[]]=;
LL tot=;
bool flag=;
LL t=clock();
LL x=f[],y=f[],z;
while(y!=)
{
if(clock()-t>=)
{
printf("-1");
exit();
break;
}
z=abs( x-y );
if(vis[z]==)
ans++,vis[z]=;
x=y,y=z;
}
printf("%lld",ans);
return ;
}

正解:

更相减损术

用除法优化减法

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;
inline LL read()
{
char c=getchar();LL flag=1,x=0;
while(c<'0'||c>'9') {if(c=='-') flag=-1;c=getchar();}
while(c>='0'&&c<='9') x=x*10+c-48,c=getchar();return x*flag;
}
LL a,b;
LL ans=0;
int main()
{
a=read();b=read();
if(a<b) swap(a,b);
LL c=a%b;
while(c)
{
ans+=a/b;
a=b;b=c;c=a%b;
}
ans+=a/b;
ans++;
printf("%lld",ans);
return 0;
}

  

T2

https://www.luogu.org/problem/show?pid=T15627

mdzz裸地暴力一分都没有啊。。。

不过30分的貌似可以套最大生成树做。。

按说用最大生成树可以过50分的,但是我不会判断t。。GG

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
const int MAXN=1e5;
const int INF=0x7ffff;
inline int read()
{
char c=getchar();int flag=,x=;
while(c<''||c>'') {if(c=='-') flag=-;c=getchar();}
while(c>=''&&c<='') x=x*+c-,c=getchar();return x*flag;
}
struct node
{
int u,v,w,nxt;
}edge[MAXN];
int head[MAXN];
int num=; inline void add_edge(int x,int y,int z)
{
edge[num].u=x;
edge[num].v=y;
edge[num].w=z;
edge[num].nxt=head[x];
head[x]=num++;
}
int t[MAXN];
int vis[MAXN]; struct node2
{
int u2,v2,w2,f2;
}edge2[MAXN];
int num2=;
inline void add_edge2(int x2,int y2,int z2)
{
edge2[num2].u2=x2;
edge2[num2].v2=y2;
edge2[num2].w2=z2;
num2++;
} int bfs(int now,int val)
{
queue<int>q;q.push(now);
int ans=;
memset(vis,,sizeof(vis));vis[now]=;
while(q.size()!=)
{
int p=q.front();q.pop();
for(int i=head[p];i!=-;i=edge[i].nxt)
if(vis[edge[i].v]==&&edge[i].w>=val)
vis[edge[i].v]=,q.push(edge[i].v),ans++;
}
return ans;
}
int fa[MAXN];
int n,m;
int comp(const node2 &a,const node2 &b)
{
return a.w2>b.w2;
}
int find(int x)
{
if(fa[x]==x) return x;
else return fa[x]=find(fa[x]);
}
inline void unionn(int x,int y)
{
fa[find(x)]=find(y);
}
void kruskal()
{
sort(edge2+,edge2+num2,comp);
int tot=;
for(int i=;i<=num2-;i++)
{
if(find(edge2[i].u2)!=find(edge2[i].v2))
{
unionn(edge2[i].u2,edge2[i].v2);
add_edge(edge2[i].u2,edge2[i].v2,edge2[i].w2);
add_edge(edge2[i].v2,edge2[i].u2,edge2[i].w2);
tot++;
if(tot==n-) break;
}
}
}
int main()
{
//freopen("car.in","r",stdin);
// freopen("car.out","w",stdout);
memset(head,-,sizeof(head));
n=read(),m=read();
for(int i=;i<=n;i++)
fa[i]=i;
if(n<=)
{
for(int i=;i<=m;i++)
{
int x=read(),y=read(),z=read();
add_edge(x,y,z);
add_edge(y,x,z);
}
for(int i=;i<=n;i++)// 枚举所有点
{
int now=,out=;
while()
{
int p=bfs(i,now);
if(p==) break;
t[now++]=p;
}
for(int i=;i<=now-;i++)
out+=abs(t[i]-t[i+])*abs(t[i]-t[i+]);
printf("%d ",out);
}
}
else
{
for(int i=;i<=m;i++)
{
int x=read(),y=read(),z=read();
add_edge2(x,y,z);
add_edge2(y,x,z);
}
kruskal();
for(int i=;i<=n;i++)// 枚举所有点
{
memset(t,,sizeof(t));
int now=,out=;
while()
{
int p=bfs(i,now);
if(p==) break;
t[now++]=p;
}
for(int i=;i<=now-;i++)
out+=abs(t[i]-t[i+])*abs(t[i]-t[i+]);
printf("%d ",out);
}
}
return ;
} /* 3 2
1 2 1
2 3 2 4 5
1 4 2
1 2 3
2 4 1
2 3 4
3 4 2 */

暴力

正解

最大生成树

用并查集维护的时候,每次维护的时候在两个点上面新开一个节点

这样就形成了一颗二叉树

剩下的就不会了。。。

https://www.luogu.org/problem/show?pid=T15628

T3

https://www.luogu.org/problem/show?pid=T15628

一眼动态规划,

很好写,但是时间复杂度是O(n*m*k)GG,一分没有

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN=;
const int INF=0x7ffff;
inline int read()
{
char c=getchar();int flag=,x=;
while(c<''||c>'') {if(c=='-') flag=-;c=getchar();}
while(c>=''&&c<='') x=x*+c-,c=getchar();return x*flag;
}
int dp[MAXN][MAXN];
// 第i个数 已经选了j个 第i个一定选 最小值
int a[MAXN];
int main()
{
// freopen("number.in","r",stdin);
// freopen("number.out","w",stdout);
int n=read(),m=read(),need=read();
memset(dp,0x3f,sizeof(dp));
for(int i=;i<=n;i++) a[i]=dp[i][]=read();
for(int i=;i<=n;i++)
for(int j=i-m;j>=;j--)
for(int k=;k<=need;k++)
dp[i][k]=min(dp[i][k],dp[j][k-]+a[i]);
int ans=INF;
for(int i=;i<=n;i++)
ans=min(ans,dp[i][need]);
printf("%d",ans);
return ;
}
/*
6 2 3
9 8 1 3 5 4 //14 5 2 2
4 7 1 1 1//2 5 2 2
4 3 44 44 1 //4 7 3 1
4 6 7 1 2 3 4// 1 7 3 3
4 6 7 1 2 3 4// 9 */

mmp。。。。。

正解

我就不吐槽啥了

这**出题人压根就没给暴力分啊。

考虑如何在O(n)内算出不考虑k,只考虑m的最大值

很显然的一个结论

设f(x)为1-n中,长度为m的限制下,选x个数的图像的增长区线

那么f(x)会增长的越来越快

二分一个c,为(k-1,f(k-1) ) 与 (k,f(k) ) 的斜率

 

 #include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=;
const LL inf=;
int n,m,x,y,z,L,sum;
int cnt[N];
LL ans0,ans;
LL f[N],s[N];
LL read()
{
LL x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
void solve(LL c)
{
int i,a,tot=;
LL ss=;
memset(cnt,,sizeof(cnt));
memset(f,,sizeof(f));
for(i=;i<=n;i++)
{
a=i-m;
if(a>=&&c-s[a]>&&(f[a]>ss||(f[a]==ss&&cnt[a]<tot)))
{
ss=f[a];
tot=cnt[a];
}
if(c-s[i]>)
{
f[i]=ss+c-s[i];
cnt[i]=tot+;
}
}
ans0=sum=;
for(i=;i<=n;i++)
if(f[i]>ans0||(f[i]==ans0&&sum>cnt[i]))
{
sum=cnt[i];
ans0=f[i];
}
// printf("%d %lld %lld\n",sum,c,ans0);
}
int pd(LL c)
{
solve(c);
if(sum<L) return ;
else return ;
}
int main()
{
int a,b,c,i,j,k;
LL l,r;
freopen("number.in","r",stdin);
freopen("number.out","w",stdout);
n=read();
m=read();
L=read();
for(i=;i<=n;i++)
s[i]=read();
// for(i=1;i<=n;i++)
// if(i%m==1) ans+=(LL)s[i];
// printf("%lld\n",ans);
ans=;
l=;
r=(LL)inf*N/;
while(l<r-)
{
LL mid=(l+r)/;
if(pd(mid)) l=mid;
else r=mid;
}
if(pd(r))
{
solve(r);
ans=(LL)L*r-ans0;
// printf("%d\n",sum);
}
else
{
solve(l);
ans=(LL)L*l-ans0;
}
printf("%lld\n",ans);
}
/*
6 5 2
100 1 1 1 1 100
*/

STD

 总结

上午那场,出题人给了:50+80+0的暴力,我正好没做T2

下午这场,出题人给了:30+30+0的暴力,我正好做了T3

mmp..

摆明了把我这种纯暴力选手往死里坑啊,,,,

不过还好明天就不是这个出题人了,(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)(*  ̄︿ ̄)

Day4下午解题报告的更多相关文章

  1. Day1下午解题报告

    预计分数:0+30+30=60 实际分数:0+30+40=70 T1水题(water) 贪心,按长度排序, 对于第一幅牌里面的,在第二个里面,找一个长度小于,高度最接近的牌 进行覆盖. 考场上的我离正 ...

  2. Day3下午解题报告

    预计分数:20+40+30=90 实际分数:40+90+60=190 再次人品爆发&&手感爆发&&智商爆发 谁能告诉我为什么T1数据这么水.. 谁能告诉我为什么T2数据 ...

  3. Day2下午解题报告

    预计分数:100+100+30=230 实际分数:100+100+30=230人品爆发&&智商爆发&&手感爆发 T3数据好水,,要是把数组开大一点的话还能多得10分,, ...

  4. Day5下午解题报告1

    预计分数:100+60+30=190 实际分数:100+60+30=190 终于有一道无脑T1了哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 ...

  5. Day4上午解题报告

    预计分数:50 +0+0=50 实际分数:50+0+10=60 毒瘤出题人,T3不给暴力分 (*  ̄︿ ̄) T1 https://www.luogu.org/problem/show?pid=T155 ...

  6. 【百度之星2014~复赛 解题报告~正解】The Query on the Tree

    声明 笔者最近意外的发现 笔者的个人网站http://tiankonguse.com/ 的很多文章被其它网站转载,但是转载时未声明文章来源或参考自 http://tiankonguse.com/ 网站 ...

  7. 冲刺Noip2017模拟赛2 解题报告——五十岚芒果酱

    题1 牛跑步(running) [题目描述] 新牛到部队,CG 要求它们每天早上搞晨跑,从 A 农场跑到 B 农场.从 A 农场到 B 农场中有 n- 个路口,分别标上号,A 农场为 号,B 农场为 ...

  8. 2014-03-01 春季PAT 1073-1076解题报告

    今天下午的PAT考试状态不理想,回来怒刷了一遍,解题报告如下: 1073. Scientific Notation (20) 基本模拟题,将一长串的科学计数转换为普通的数字表示方式.思路是是数组存储输 ...

  9. 【LeetCode】481. Magical String 解题报告(Python)

    [LeetCode]481. Magical String 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http:/ ...

随机推荐

  1. COGS——T1588. [USACO FEB04]距离咨询

    http://cogs.pro/cogs/problem/problem.php?pid=1588 ★★   输入文件:dquery.in   输出文件:dquery.out   简单对比时间限制:1 ...

  2. 洛谷 P3068 [USACO13JAN]派对邀请函Party Invitations

    P3068 [USACO13JAN]派对邀请函Party Invitations 题目描述 Farmer John is throwing a party and wants to invite so ...

  3. [Recompose] Refactor React Render Props to Streaming Props with RxJS and Recompose

    This lesson takes the concept of render props and migrates it over to streaming props by keeping the ...

  4. C++关于二进制位操作小结

    #include <iostream> using namespace std; //二进制位逆序. int Grial(int x) { int n = 32; int count = ...

  5. HDU 3853 向下向右找出口问题-期望dp

    题意:初始状态在(1,1)的位置.目标是走到(n,n).每次仅仅能向下向右或者不移动.已知在每一个格子时这三种情况的概率,每移动一步消耗2的魔力,求走到终点的使用的魔力的期望. 分析:简单的期望dp, ...

  6. export和source的区别

    1.执行脚本是在一个子shell环境运行的,脚本执行完后该子shell自动退出. 2.执行脚本中的系统环境变量(用export定义的变量)才会被复制到子shell中. 3.一个shell中的系统环境变 ...

  7. HDU 5438 Ponds dfs模拟

    2015 ACM/ICPC Asia Regional Changchun Online 题意:n个池塘,删掉度数小于2的池塘,输出池塘数为奇数的连通块的池塘容量之和. 思路:两个dfs模拟就行了 # ...

  8. Docker -- 2 -- 利用docker部署网站和数据库

    在Docker – 系统整洁之道 – 1中已经对Docker的一些命令和Docker镜像的使用及操作做了记录. 这次就利用docker进行一次真正的实例使用,使用docker搭建一个简单的答题系统,这 ...

  9. ireport 追加新报表

    ireport  追加新报表 /* To change this template, choose Tools | Templates * and open the template in the e ...

  10. Python入门:全站url爬取

    <p>作为一个安全测试人员,面对一个大型网站的时候,手工测试很有可能测试不全,这时候就非常需要一个通用型的网站扫描器.当然能直接扫出漏洞的工具也有很多,但这样你只能算是一个工具使用者,对于 ...