预计分数: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. 虚构造函数与prototype

    注意,构造函数不能是虚的,不然不会生效?(构造函数里面调用虚的函数,也不会生效). 而虚构造函数,指的是通过一个虚函数,来调用clone方法,生成一个新的实例.而这个clone里面,一般调用的是拷贝构 ...

  2. 常量成员函数的注意事项 & mutable的使用场景

    mutable的使用场景: 可以在一个const的对象里面,解除对部分字段的const限制.也可以用在const成员函数里面. 对于const与否,一般会调用不同版本的函数: 而对于二元操作符,如果用 ...

  3. Please ensure that adb is correctly located at &#39;D:\Android\android-sdk\platform-tools\adb.exe&#39; and

    1.启动任务管理器 2.找到百度安全组件杀掉进程. 3.一般都是组件给禁止了.

  4. git帮助命令

    git帮助命令 零.自己实例 cd D://software/code/PHP/phpStudy/PHPTutorial/WWW/github/m_Orchestrate git checkout - ...

  5. js --- 中字符串与unicode编码

    1.charAt():把字符串分成每一个字符,从左往右提取指定位置的字符 var str = '天气'; alert( str.charAt(1) );            //气 2.charCo ...

  6. 二分法查找 js 算法

    二分法查找算法:采用二分法查找时,数据需是排好序的.主要思想是:(设查找的数组区间为array[s, e])(1)确定该区间的中间位置m(2)将查找的值T与array[m]比较,若相等,查找成功返回此 ...

  7. AIX 系统补丁升级步骤

    AIX 系统补丁升级步骤   1.升级之前建议备份 rootvg (推荐) # smit mksysb   2.检查系统版本号 # oslevel -r   3.找到补丁光盘或者下载补丁,上传到服务器 ...

  8. Ubuntu Bonding(16.04网卡绑定)

    UbuntuBonding(网卡绑定) 绑定,也称为端口聚合或链路聚合,意味着将多个网络接口(NIC)组合到单个链路,从而提供高可用性,负载平衡,最大吞吐量或这些组合.注意bonding只能提供链路监 ...

  9. js003-4方向8方向函数

    1,求四方向或者8方向的周围的棋子. /** * pos 1-4, 1-8 4/8方向的周围 * @param {*} pos * @param {*} dir */ var _nearChess = ...

  10. Java并发包之Semaphore用法

    多线程中的同步概念就是排着队去执行一个任务,执行任务的是一个一个的执行,并不能并行执行,这样的优点是有助于程序逻辑的正确性,不会出现线程安全问题,保证软件的系统功能上的运行稳定性, Semaphore ...