综述

试题为常州集训2019SCDay2

得分\(100+30(0)+28\)


时之终结

问题描述

HZOJ1310

题解

构造题。

发现部分分有一档是 \(Y\) 是 \(2^x\) ,于是自然想到很多个三角形连到一起。

然后正解就是在这个基础上删边。

\(\mathrm{Code}\)

#include<bits/stdc++.h>
using namespace std; #define int long long template <typename Tp>
void read(Tp &x){
x=0;char ch=1;int fh;
while(ch!='-'&&(ch>'9'||ch<'0')) ch=getchar();
if(ch=='-') ch=getchar(),fh=-1;
else fh=1;
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=fh;
} int y,opt=2;
bool eps[1007]; bool deal(){
int bf=y,cnt=0;
while(1){
if(bf&1) return (bf==1);
++cnt;bf>>=1;++opt;
}
return 0;
} namespace Subtask_2{
void solve(){
printf("%lld %lld\n",opt,opt*(opt-1)/2);
for(int i=1;i<opt;i++){
for(int j=i+1;j<=opt;j++) printf("%lld %lld\n",i,j);
}
}
} namespace Subtask_3{
void solve(){
int bf=y;opt=2;int tmp=1;
while(bf){
eps[opt]=(bf&1);bf>>=1;
tmp+=(eps[opt]==0);++opt;
}
printf("%lld %lld\n",opt,opt*(opt-1)/2-tmp);
for(int i=1;i<opt;i++){
for(int j=i+1;j<=opt;j++){
if(j==opt&&!eps[i]) continue;
printf("%lld %lld\n",i,j);
}
}
}
} signed main(){
freopen("review.in","r",stdin);freopen("review.out","w",stdout);
read(y);
if(y==1){
puts("2 1");puts("1 2");
fclose(stdin);fclose(stdout);
return 0;
}
if(y==2){
puts("3 3");puts("1 2");puts("2 3");puts("1 3");
fclose(stdin);fclose(stdout);
return 0;
// 3 3 1 2 2 3 1 3
}
if(deal()) Subtask_2::solve();
else Subtask_3::solve();
return 0;
}

博士之时

问题描述

HZOJ1311

题解

想象它是肽链和肽环

正难则反

链只能倒过来,环随便转

注意长度相同的链、长度相同的环可以互换。

\(\mathrm{Code}\)

#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e5+10;
const int M=5e5+10;
const int mod=1e9+7;
int Num,n,m1,m2,A,B,head[N],cnt,n0,n1,n2,n3,f[N][2],opt,g[N],fac[N],ans,num,tot,bin[N];bool d[N],w[N],vis[N],pd;//f链,g环
bool cc[20][20],dd[20][20];
struct edge{int nxt,to;}ed[M<<1];
inline void addedge(int x,int y){
ed[++cnt].to=y;ed[cnt].nxt=head[x];head[x]=cnt;
ed[++cnt].to=x;ed[cnt].nxt=head[y];head[y]=cnt;}
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int MOD(int x){x-=x>=mod? mod:0;return x;}
inline int Minus(int x){x+=x<0? mod:0;return x;}
inline int fas(int x,int p){int res=1;while(p){if(p&1)res=1ll*res*x%mod;p>>=1;x=1ll*x*x%mod;}return res;}
inline void DFS(int u){
vis[u]=true;num++;int record=0;
for(register int i=head[u];i;i=ed[i].nxt){
int v=ed[i].to;if(vis[v]){record++;continue;}
DFS(v);
}
if(!ed[head[u]].nxt)opt=w[u];
if(record==2)pd=true;
}
int main(){
freopen("refrain.in","r",stdin);
freopen("refrain.out","w",stdout);
scanf("%d",&Num);
scanf("%d%d%d",&n,&m1,&m2);
for(register int i=1;i<=m1;i++){
scanf("%d%d",&A,&B);
d[A]=true;d[B]=true;addedge(A,B);
}
for(register int i=1;i<=m2;i++){
scanf("%d%d",&A,&B);
w[A]=true;w[B]=true;addedge(A,B);
}
fac[0]=1;for(register int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
bin[0]=1;for(register int i=1;i<=n;i++)bin[i]=2ll*bin[i-1]%mod;
ans=fac[n];
for(register int i=1;i<=n;i++)
if(!vis[i]){
num=0;pd=false;DFS(i);
if(num==1)n0++;
else if(num==2){if(d[i]&&w[i])n3++;else if(d[i])n1++;else n2++;}
else if(pd)g[num]++;else f[num][opt]++;
}
tot=fac[n0];
tot=1ll*tot*fac[n1]%mod*bin[n1]%mod;
tot=1ll*tot*fac[n2]%mod*bin[n2]%mod;
tot=1ll*tot*fac[n3]%mod*bin[n3]%mod;
for(register int i=3;i<=n;i++)
if(i&1)tot=1ll*tot*fac[f[i][0]+f[i][1]]%mod;
else tot=1ll*tot*fac[f[i][0]]%mod*bin[f[i][0]]%mod*fac[f[i][1]]%mod*bin[f[i][1]]%mod;
for(register int i=4;i<=n;i+=2)
tot=1ll*tot*fac[g[i]]%mod*fas(i,g[i])%mod;
ans=Minus(ans-tot);
printf("%d\n",ans);
return 0;
}

曾有两次

问题描述

HZOJ1312

题解

不会

最新文章

  1. sql中的!=判断的注意事项
  2. 2016总结 wjwdive
  3. Xshell 中文乱码
  4. 集合类学习之ArrayList源码解析
  5. 理解Windows中的路由表和默认网关
  6. systemtap [主设备号,次设备好,inode]监控文件
  7. Sonar安装与使用说明
  8. struts2.1.6教程四_2、ActionContext 、ValueStack 、Stack Context
  9. hadoop单机版安装及基本功能演示
  10. R+OCR︱借助tesseract包实现图片文本提取功能
  11. codeforces round 425 div2
  12. 动手实现linux中的cp命令(可自行拓展)
  13. Netstat状态分类
  14. 我遇到的response.sendRedirect跳转不了问题
  15. 【原创】大数据基础之Ambari(4)通过Ambari部署Impala
  16. IIS无法删除应该程序池 因为它包含X个应用程序
  17. bzoj 3626 : [LNOI2014]LCA (树链剖分+线段树)
  18. &#39;mysql&#39; 不是内部或外部命令,也不是可运行的程序 或批处理文件。
  19. JavaScript 原型链学习(三)原型对象存在的问题 与 组合使用构造函数和原型
  20. ASP.NET异步

热门文章

  1. CF-378 B.Semifinals
  2. Vue+Element UI 实现视频上传
  3. Loj #2719. 「NOI2018」冒泡排序
  4. 获取主机信息,网络信息AIP,getsockname,getpeername,getservbyname,getservbyport,inet_ntop,inet_pton
  5. 迷你版mybatis
  6. Clickhouse单机部署以及从mysql增量同步数据
  7. Ribbon架构剖析
  8. 实验6:Mapreduce实例——WordCount
  9. 网页跳H5实例
  10. SQL的概念与发展 - 极客时间学习笔记