151104 系统坑爹计
来源:互联网 发布:存储数据的最小单位 编辑:程序博客网 时间:2024/06/12 01:43
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"></span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">T1最后说</span>
T2
看着像费用流?然后大致写了一下
然后发现点数爆炸只能过暴力。。话说暴力可过为什么费用流?
然后写了搜索,堆优化复杂度
最后T了6个点
下来后:
czh勇士:这题不是做过么
翻了以前的代码,搜索居然过掉了。。于是今天也搜索了。。 40
正解dp。。话说这道题叫做dp真的敢dp?
可以设置第一维当前点,第二维当前状态,维护一下,外面套个二份答案就好啦
T3
好简单的题,结论显然,但是不敢用
写了对拍发现没问题就过掉了 100
回来说T1
这道题要说说坑爹的系统
#ifdef WIN32#define lld "%I64d"#else#define lld "%lld"#endif#define ll long long#define ull unsigned long long#define mod (4294967296ll)
这玩意lemon不认啊!!linux下认I64d!!
然后就坑爹了,,,7个点输出负数
然而我去windows和linux都试过了能用的
说好的在linux下评测呢。。
30->100 考试记得lld啊
这道题有个trick 要开unsignedlonglog或者unsignedint自动取模
//Copyright(c)2015 Liuchenrui#include <iostream>#include <cstdio>#include <cstring>#include <ctime>#include <cstdlib>#define ll long long#define ull unsigned long long#define mod (4294967296ull)using namespace std;void R(ull &v){v=0;bool k=true;char c=0;while(c>'9' || c<'0'){c=getchar();if(c=='-')k=false,c=getchar();}while(c>='0' && c<='9'){v*=10,v+=c-'0';c=getchar();}if(!k)v=-v;}ull ans[100];ull s[100];ull q[100];void init(){ans[1]=0;ull now=1;for(ull i=2;i<=70;i++){if(i>=3)now=now*3ull%mod;ans[i]=((ans[i-1]<<1)%mod+(1ull<<(i-2))%mod*now)%mod;}now=1;for(ull i=1;i<=70;i++){if(i>=2)now*=3ull;ans[i]+=now;ans[i]%=mod;}for(ull i=0;i<=69;i++)ans[i]=ans[i+1];for(int i=0;i<=69;i++)s[i]=(ull)ans[i];q[1]=1;for(int i=2;i<=69;i++)q[i]=q[i-1]*3ull%mod;}ull calc(ull x){ull now=0,ret=0;for(ull i=62;i>=0;i--){if((1ull<<i)<=x){ret+=(((ull)(1ull<<i)%mod*(ull)now)%mod+s[i])%mod;now+=q[i+1];now%=mod;x-=(1ull<<i);}if(i==0)break;}return ret;}int main(){freopen("number.in","r",stdin);freopen("number.out","w",stdout);init();ull T;R(T);while(T--){ull l,r;R(l),R(r);ull k1=calc(r);ull k2=calc(l-1);printf("%I64d\n",(k1-k2+mod)%mod);}}
//Copyright(c)2015 Liuchenrui#include <iostream>#include <cstdio>#include <cstring>#include <ctime>#include <cstdlib>#include <algorithm>#define inf 1000000000using namespace std;void R(int &v){v=0;bool k=true;char c=0;while(c>'9' || c<'0'){c=getchar();if(c=='-')k=false,c=getchar();}while(c>='0' && c<='9'){v*=10,v+=c-'0';c=getchar();}if(!k)v=-v;}int f[110][3000],h[110],w[110],c[110],d[110][3000];int n,i,j,k,m,ans;bool check(int x){int cost=0,ret=inf;memset(f,63,sizeof f);if(h[1]+w[1]>=x)f[1][1<<(k-1)]=c[1];if(h[1]>=x)f[1][0]=0;d[1][0]=0;d[1][1<<(k-1)]=w[1];for(i=2;i<=n;i++){for(j=0;j<(1<<k);j++){int num=((1<<(k-1))-1)&j;cost=min(f[i-1][num<<1],f[i-1][num<<1^1]);d[i][j]=d[i-1][num<<1]+(j>>(k-1))*w[i];if(h[i]+d[i][j]>=x) f[i][j]=cost+(j>>(k-1))*c[i]; }}for(i=0;i<(1<<k);i++)ret=min(ret,f[n][i]);if(ret<=m)return true;return false;}int main(){freopen("dp.in","r",stdin);R(n),R(m),R(k);<pre name="code" class="cpp">//Copyright(c)2015 Liuchenrui#include <iostream>#include <cstdio>#include <cstring>#include <ctime>#include <cstdlib>#define ll long longusing namespace std;void R(int &v){v=0;char c=0;while(c>'9' || c<'0'){c=getchar();}while(c>='0' && c<='9'){v*=10,v+=c-'0';c=getchar();}}int mp[1005][1005];int fx[1005],fy[1005];int n,m,q;int main(){freopen("change.in","r",stdin);freopen("change.out","w",stdout);R(n),R(m),R(q);for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)R(mp[i][j]);for(int i=1;i<=1001;i++)fx[i]=fy[i]=i;while(q--){static char c;while(c=getchar())if(c>='a' && c<='z')break;static int x,y;R(x),R(y);switch(c){case 'c':swap(fy[x],fy[y]);break;case 'r':swap(fx[x],fx[y]);break;case 'g':cout<<mp[fx[x]][fy[y]]<<endl;}}}
int l=0,r=inf;for(i=1;i<=n;i++)R(h[i]),R(w[i]),R(c[i]);while(l<r){int mid=l+r>>1;if(check(mid))l=mid+1;else r=mid;}printf("%d",l-1);return 0;}
0 0
- 151104 系统坑爹计
- 系统
- 《系统》
- 系统
- 系统
- 系统
- 系统
- 系统
- 系统
- 系统
- 系统
- 系统系统!!!
- 二级域名系统?虚拟主机系统?
- 系统寄存器 系统指令
- 应激系统 排泄系统
- 【小型系统】抽奖系统
- 系统移植-系统搭建
- 开源 CMS系统 / SNS系统 / BBS系统
- Eye-Dome-Lighting (EDL)
- 文章标题
- 识别,基于内容的检索,检测
- linux_sqlite3学习
- Conditionvariable的用法
- 151104 系统坑爹计
- 字符编码问题
- centos 64 python2.6升级到2.7后中文输入法问题
- Unity5 Screen-Space Subsurface Scattering屏幕空间次表面散射SSSSS
- Java中有关Null的9件事
- (一)ActiveMQ学习教程——安装(和topic实例)
- centos中apache配置
- Android动画的优化
- 由于加了mahout*.job.jar进hadoop2.X/share/hadoop/common/lib重启datanode闪退报错