Day5上午解题报告
预计分数:100+40+30=170
实际假分数:0+0+0=0 CE*3
实际真分数:60+50+0=110
老师没把我的程序放的文件夹里面,于是。。。。。
T1
https://www.luogu.org/problem/show?pid=T15678
一眼秒C(n,k)
组合数,
不过数组少开了1.。。翻车了呜呜呜~~~~(>_<)~~~~
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
const LL MAXN=*1e6;
const LL INF=0x7ffff;
const LL mod=1e9+;
const LL limit=*1e6+;
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 n,k;
LL a[MAXN];
LL js[MAXN];
LL x,y;
LL exgcd(LL a,LL b,LL &x,LL &y)
{
if(b==)
{
x=,y=;return a;
}
LL r=exgcd(b,a%b,x,y)%mod;
LL tmp=x%mod;x=y%mod;y=tmp-(a/b)*y%mod;
return r%mod;
}
LL C(LL n,LL k)
{
LL r=exgcd((js[n-k]%mod*js[k]%mod)%mod,mod,x,y);
while(x<)
x+=mod;
LL yy1=js[n]%mod;
LL xx1=x%mod;
LL rt=((LL)yy1*xx1)%mod;
return rt;
}
int main()
{
//12 freopen("cube.in","r",stdin);
// freopen("cube.out","w",stdout);
n=read();k=read();
// for(LL i=1;i<=n;i++)
// a[i]=read();
js[]=;
for(LL i=;i<=limit;i++) js[i]=((LL)js[i-]%mod*i%mod)%mod;
LL ans=C(n,k)%mod;
printf("%lld",ans%mod);
return ;
} /*
3 2
1 1 0
//3 4 2
0 0 0 0 //6 5 3
1 0 1 0 1//10
// */
T2
没想到正解
正解其实很简单
先求最大生成树
在建最大生成树的时候记录下选择k次的最大限重
每次二分查找
考场上为了求稳光敲了暴力
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=1e6+;
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 n,m,q;
int fa[MAXN];
struct node
{
int u,v,w;
}edge[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;num++;
}
int comp(const node &a,const node &b)
{
return a.w>b.w;
}
int find(int x)
{
if(fa[x]==x) return fa[x];
else return fa[x]=find(fa[x]);
}
inline void unionn(int a,int b)
{
fa[find(a)]=find(b);
}
int happen[MAXN];
int cnt=;
inline void Kruskal()
{
sort(edge+,edge+num,comp);
int tot=;
for(int i=;i<=num-;i++)
{
if(find(edge[i].u)!=find(edge[i].v))
{
unionn(edge[i].u,edge[i].v);
happen[++cnt]=edge[i].w;
tot++;
if(tot==n-) break;
}
}
reverse(happen+,happen+cnt+);
}
int main()
{
n=read();m=read();q=read();
for(int i=;i<=n;i++) fa[i]=i;
for(int i=;i<=m;i++)
{
int x=read(),y=read(),z=read();
add_edge(x,y,z);
}
Kruskal();
for(int i=;i<=q;i++)
{
int p=read();
int pos=lower_bound(happen+,happen+cnt+,p)-happen;
printf("%d\n",pos);
}
return ;
}
t2
T3
写了30分的暴力,但是被卡T了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
const int MAXN=1e4+;
const int INF=0x7ffff;
const int mod1=;
const int mod2=;
const int mod =1e9+;
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 n,q;
char word[MAXN][];
int len[MAXN];
int sum[MAXN];//长度>=i的单词有多少个
int mxlen=;
int hash[MAXN*];
bool pd(int now,int nowlen,int will,int need)
{
if(need-nowlen>len[will]) return ;
unsigned int seed=;
unsigned LL h=;
for(int i=;i<=nowlen;i++)
h=(h+( (seed*word[now][i])%mod2))%mod1,seed=seed*seed;
for(int i=len[will]-(need-nowlen)+;i<=len[will];i++)
h=(h+( (seed*word[will][i])%mod2))%mod1,seed=seed*seed;
h=h%mod1;
if(hash[h]==)
{
hash[h]=;
return ;
}
return ;
}
int main()
{
// freopen("word.in","r",stdin);
// freopen("word.out","w",stdout);
n=read(),q=read();
for(int i=;i<=n;i++)
{
scanf("%s",word[i]+);
len[i]=strlen(word[i]+);
mxlen=max(len[i],mxlen);
for(int j=len[i];j>=;j--)
sum[j]++;
}
for(int i=;i<=q;i++)
{
memset(hash,,sizeof(hash));
int qr=read(),ans=;
for(int j=;j<=n;j++)//枚举每个单词
for(int k=;k<=min(len[j],qr-);k++)//这个单词的长度
for(int l=;l<=n;l++)// 枚举其他的单词
if(pd(j,k,l,qr)==)
{
/* for(int o=1;o<=k;o++) cout<<word[j][o];
for(int o=len[l]-(qr-k)+1;o<=len[l];o++) cout<<word[l][o];
cout<<endl;*/
ans=(ans+)%mod;
}
printf("%d\n",ans%mod);
}
return ;
} /*
2 2
cool
at
6
3 //7 \n 5
*/
正解:
没听懂。。。。。
总结
终于翻了一次车了(啪,成天打暴力还好意思翻车)
T2没想到正解,,好失败啊。。。。
T3被卡成零分。。
交题的时候因为各种原因老师忘记把我的程序放到文件夹里了。。
GG
Day5上午解题报告的更多相关文章
- Day1上午解题报告
预计分数:100+60+0=160 实际分数:100+30+20=150 T1立方数(cubic) 题目描述 LYK定义了一个数叫“立方数”,若一个数可以被写作是一个正整数的3次方,则这个数就是立方数 ...
- Day2上午解题报告
预计分数:100+0+60=160 实际分数:100+0+60=160 mmpT1数据错了... T1遭遇 题目描述 你是能看到第一题的 friends呢. —— hja ?座楼房,立于城中 . 第? ...
- Day3上午解题报告
预计分数:100+40+50=190 实际分数:100+40+50=190 T1 https://www.luogu.org/problem/show?pid=T15365 表示从来没做过博弈论的题, ...
- Day5下午解题报告1
预计分数:100+60+30=190 实际分数:100+60+30=190 终于有一道无脑T1了哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 ...
- Day4上午解题报告
预计分数:50 +0+0=50 实际分数:50+0+10=60 毒瘤出题人,T3不给暴力分 (*  ̄︿ ̄) T1 https://www.luogu.org/problem/show?pid=T155 ...
- 夏令营提高班上午上机测试 Day 4 解题报告
我要是没记错的话,今天的题难度算挺适中的. *标程来自高天宇哥哥 T1:小G的字符串 题目描述 有一天,小 L 给小 G 出了这样一道题:生成一个长度为 n 的.全由小写英文字母构成的字符串,只能使用 ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- 【LeetCode】306. Additive Number 解题报告(Python)
[LeetCode]306. Additive Number 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http: ...
- CH Round #56 - 国庆节欢乐赛解题报告
最近CH上的比赛很多,在此会全部写出解题报告,与大家交流一下解题方法与技巧. T1 魔幻森林 描述 Cortana来到了一片魔幻森林,这片森林可以被视作一个N*M的矩阵,矩阵中的每个位置上都长着一棵树 ...
随机推荐
- 洛谷——P3368 【模板】树状数组 2
https://www.luogu.org/problem/show?pid=3368 题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数数加上x 2.求出某一个数的和 输入 ...
- cocoapods的安装,使用,卸载,以及你可能会遇到的坑..
首先, 不会用cocoapods的话如过你接手某些新项目是用cocoapods写的你会疯, 其次他真的非常好用, 当然某些坑也是存在的,比方你用它导入了AFNetwork然后你须要改动一些AF的内部的 ...
- VGA接口时序约束
SF-VGA模块板载VGA显示器DA转换驱动芯片AVD7123,FPGA通过OUPLLN连接器驱动ADV7123芯片产生供给VGA显示器的色彩以及同步信号.SF-CY3核心模块与SF-VGA子模块连接 ...
- fs路径位置与widget路径转换
var fs = api.require('fs'); fs.exist({ path: 'fs://res/yltmusic.mp4' }, function(ret, err) { if (!re ...
- Google Nexus 5x Android 7.0 Root
很久没有写东西了,准备重新养成这个好习惯.因为自己一直在用Nexus,前段时间自己的Nexus5老的不行了,所以买了台5x,一直没时间root,今天有时间终于有时间弄一下. 在这里整理分享一下. 开始 ...
- drbd脑裂
环境: Primary 节点:node1Secondary 节点:node2 DRBD产生脑裂的原因: (1. 采用HA环境的时候自动切换导致脑裂; (2. 人为操作或配置失误,导 ...
- 【Django】Cookie
目录 Cookie介绍 操作Cookie 获取Cookie 设置 Cookie 删除Cookie @ Cookie介绍 Cookie的由来 大家都知道==HTTP协议是无状态的==. ==无状态的的意 ...
- php自定义加密和解密
<?php function _authcode($string, $operation = 'DECODE', $expiry = 0) { $key = 'c5s1t6o'; $cke ...
- Swift学习笔记(13)--属性 (Properties)
普通属性用var和let即可,本文不做详述 1.延迟存储属性 延迟存储属性是指当第一次被调用的时候才会计算其初始值的属性.在属性声明前使用@lazy来标示一个延迟存储属性. class DataImp ...
- SpringBoot结合Mybatis 使用 mapper*.xml 进行数据库增删改查操作
什么是 MyBatis? MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架. MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及对结果集的检索. MyBa ...