Test 2017.10.24
来源:互联网 发布:手机屏幕动物软件 编辑:程序博客网 时间:2024/05/01 06:13
30/5/0
第一题
tarjin+缩点
缩点建边的时候,以为一个双连通分量low值是一样的,结果居然不一样,这少了30。
结论是(叶子节点数+1)/2;
我打的叶子节点数-1,这少了40
就30了。
第二题
状压dp(表示不会)
本来是手玩的40分
结果玩漏了一个,还玩错了一个就只有5分
上波正解
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<ctime>#include<cmath>#include<algorithm>#include<vector>using namespace std;inline int read(){ int i=0,f=1; char ch; for(ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=-1; for(;isdigit(ch);ch=getchar()) i=(i<<3)+(i<<1)+(ch^48); return i*f;}const int maxn=505;const int mod=1000000007;int p[]={2,3,5,7,11,13,17,19};int T,n,k,a[maxn],sta[maxn],dp[maxn][259];unsigned char temp[maxn];vector<int>v[maxn];inline void inc(register int &a,register int &b){ a=a+b>mod ? a+b-mod:a+b;}int main(){ freopen("mul.in","r",stdin); freopen("mul.out","w",stdout); cin>>T; while(T--) { n=read(); k=read(); for(int i=1;i<=n;i++) v[i].clear(),sta[i]=0; for(int i=1;i<=n;i++) { a[i]=i; for(int j=0;j<8;j++) if(a[i]%(p[j]*p[j])==0)sta[i]=-1; else if(a[i]%p[j]==0) a[i]/=p[j],sta[i]|=(1<<j); } for(int i=1;i<=n;i++) { if(~sta[i]) { if(a[i]==1)v[i].push_back(i); else v[a[i]].push_back(i); } } memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=n;i++) { if(~sta[i]&&v[i].size()) { register int sz=v[i].size(); for(int j=0;j<sz;j++) temp[j]=sta[v[i][j]]; for(register int j=k-1;j>=0;j--) for(register int l=0;l<sz;l++) for(register int v=temp[l],s=255^v;;s=(s-1)&(255^v)) { if((s&temp[l])==0) inc(dp[j+1][s|v],dp[j][s]); if(!s)break; } } } long long ans=0; for(register int i=1;i<=k;i++) for(register int j=0;j<256;j++) { ans+=dp[i][j]; } cout<<ans%mod<<endl; } return 0;}
第三题
一道结论题,并没有看出来
打的暴力快速幂 本来有30的
结果脑抽,加了个快速乘(以为叫快速乘应该要快点,结果苍天弄人),直接T了
阅读全文
0 0
- Test 2017.10.24
- Test 2017.10.16
- Test 2017.10.06
- Test 2017.10.08
- Test 2017.10.09
- Test 2017.10.11
- Test 2017.10.13
- TEst 2017.10.14
- Test 2017.10.16
- Test 2017.10.17
- Test 2017.10.19
- Test 2017.10.20
- Test 2017.10.23
- Test 2017.10.26
- Test 2017.10.27
- Test 2017.10.30
- Test 2017.10.31
- Loi test 2015.5.24
- nginx 服务器上Laravel5.1框架的一些配置
- 腾讯云 centos7 配置服务器所需要知道的
- 面试Java web,有关于hibernate一般都问什么问题?
- 自定义浏览器协议,实现web页面调用本地程序
- EA&UML日拱一卒-状态图::状态机
- Test 2017.10.24
- codeforces #442 B
- 基本图像变换:线性变换,仿射变换,投影变换
- 求最大和最小值(SDIBTOJ 2001)
- 【软件安装】Windows下Anaconda安装+tensorflow安装
- Sublime text3注册码
- 《代码整洁之道》
- bootstrap datetimepicker日期插件超详细使用方法介绍
- Mysql数据库的优化