17.10.05

  • 上午
    • 模拟考试
      • Prob.1(AC)一道简单的博弈题,找到必胜态,反推普遍情况是否可以达到必胜态即可。
      • Prob.2(AC)做到原题了呢。入门OJ 2092: [Noip模拟题]舞会
      • Prob.3(WA了3个点)一道高精度的dp题,为减少状态,我把数据按某一权值分为了两类,对于一类反着dp,状态很少,只用到高精度加法。对于另一类(30分),要用到高精度乘法,然后进位时少打了一个+号,然后就没有然后了……
    • 然后整理了三个模板,贴上!
      //maybe have no mistakes,^_^//1.Big_Int
      //only support + , * , = , < , <= , > , >= between Big_Int and Big_Int as well as Big_Int and int 
      #define MAXN 1000
      struct Big_Int{int len,a[30];Big_Int(){len=1; memset(a,0,sizeof(a));}void operator =(int val){len=0;do{a[++len]=val%MAXN;val/=MAXN;}while(val);}Big_Int operator +(const Big_Int &rtm) const{Big_Int now; int l=max(len,rtm.len);for(int i=1;i<=l;i++){now.a[i]+=a[i]+rtm.a[i];now.a[i+1]=now.a[i]/MAXN;now.a[i]%=MAXN;}if(now.a[l+1]) l++; now.len=l;return now;}Big_Int operator +(const int &val) const{Big_Int now,rtm;rtm=val; now=(*this)+rtm;return now;}Big_Int operator *(const Big_Int &rtm) const{Big_Int now; int l=len+rtm.len;for(int i=1;i<=len;i++)for(int j=1;j<=rtm.len;j++){now.a[i+j-1]+=a[i]*rtm.a[j];now.a[i+j]+=now.a[i+j-1]/MAXN;now.a[i+j-1]%=MAXN;}while(!now.a[l]) l--; now.len=l;return now;}Big_Int operator *(const int &val) const {Big_Int now,rtm;rtm=val; now=(*this)*rtm;return now;}bool operator ==(const Big_Int & rtm) const{if(len!=rtm.len) return 0;for(int i=len;i>=1;i--) if(a[i]!=rtm.a[i]) return 0;return 1;}bool operator <(const Big_Int &rtm) const{if(len!=rtm.len) return len<rtm.len;for(int i=len;i>=1;i--) if(a[i]!=rtm.a[i]) return a[i]<rtm.a[i];return 0;}bool operator >(const Big_Int &rtm) const{return rtm<(*this);}bool operator <=(const Big_Int &rtm) const{return (*this)<rtm||(*this)==rtm;}bool operator >=(const Big_Int &rtm) const{return (*this)>rtm||(*this)==rtm;}bool operator ==(const int &val) const{Big_Int rtm; rtm=val;return (*this)==rtm;}bool operator <(const int &val) const{Big_Int rtm; rtm=val;return (*this)<rtm;}bool operator >(const int &val) const{Big_Int rtm; rtm=val;return (*this)<rtm;}bool operator <=(const int &val) const{Big_Int rtm; rtm=val;return (*this)<=rtm;}bool operator >=(const int &val) const{Big_Int rtm; rtm=val;return (*this)>=rtm;}void print(){printf("%d",a[len]);for(int i=len-1;i>=1;i--){printf("%03d",a[i]);}}
      };//2.Fraction
      //only support + , * and  reduction for fraction
      struct Fraction{ll Numerator,Denominator;ll Gcd(ll a,ll b){while(a^=b^=a^=b%=a);return b;}bool Zero(){return Numerator==0;}void Clear(){Numerator=Denominator=0;}void Reduction(){ll g=Gcd(Numerator,Denominator);Numerator/=g;Denominator/=g;}Fraction operator +(Fraction &rtm){Fraction New;if(!Numerator&&!Denominator) New.Numerator=rtm.Numerator,New.Denominator=rtm.Denominator;else{ll g=Gcd(Denominator,rtm.Denominator);ll a=Denominator/g,b=rtm.Denominator/g;New.Denominator=a*b*g;New.Numerator=Numerator*b+rtm.Numerator*a;}New.Reduction();return New;}Fraction operator *(Fraction &rtm){Fraction New;New.Denominator=Denominator*rtm.Denominator;New.Numerator=Numerator*rtm.Numerator;New.Reduction();return New;}void Read(){cin>>Numerator;Denominator=1;}void Write(){cout<<Numerator;if(Denominator!=1&&Denominator!=0) cout<<"/"<<Denominator<<endl;}
      }//3.Maxtrix
      //noly supprt * , ^(quick pow) for Maxtrix
      struct Maxtrix{int r,c;int val[75][75];Maxtrix(){r=c=0;memset(val,0,sizeof(val));}void identity(int l){r=c=l;for(int i=1;i<=l;i++) val[i][i]=1;}Maxtrix operator * (Maxtrix const b){  // c==b.rMaxtrix now; now.r=r; now.c=b.c;for(int i=1;i<=r;i++)for(int j=1;j<=b.c;j++)for(int k=1;k<=c;k++)now.val[i][j]=(now.val[i][j]+val[i][k]*b.val[k][j])%mod; return now;} Maxtrix operator ^ (int b){Maxtrix base,now; base=*this;now.identity(this->r); while(b){if(b&1) now=now*base;base=base*base;b>>=1; }return now;}
      }//____________________________________________________________________by *ZJ

 

  • 下午
    • 入门OJ 2069: [Noip模拟题]贪吃的CWT

      对拍了一下,改出来了呢。

      知道了错误在哪儿的我想打人……

      这是我原来错误的dis函数:

      image

      (真不知道是什么鬼样例数据,dis没开根都过了)

      代码:

      #include<cmath>
      #include<cstdio>
      #include<cstring>
      #include<iostream>
      #include<algorithm>
      using namespace std;
      struct edge{int u,v; double val;bool operator<(const edge &rtm) const{return val<rtm.val;} 
      }e[1005*1005];
      struct hamburger{int x,y,val;
      }p[1005];
      int fa[1005],bh[1005];
      int n,ent; 
      double tot,ans;
      double dis(int i,int j){return sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y));
      }
      int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);
      }
      int main(){scanf("%d",&n);for(int i=1,a,b,c;i<=n;i++){scanf("%d%d%d",&a,&b,&c);p[i]=(hamburger){a,b,c};}for(int i=1;i<n;i++)for(int j=i+1;j<=n;j++)e[++ent]=(edge){i,j,dis(i,j)};sort(e+1,e+ent+1);for(int i=1;i<=n;i++) fa[i]=i;int fu,fv,u,v,need=n-1;for(int i=1;i<=ent&&need;i++){u=e[i].u; v=e[i].v;fu=find(u); fv=find(v);if(fu==fv) continue;tot+=e[i].val;fa[fv]=fu;need--;}for(int i=1;i<=n;i++) fa[i]=i;for(int i=1;i<=n;i++) bh[i]=p[i].val;need=n-1;for(int i=1;i<=ent&&need;i++){u=e[i].u; v=e[i].v;fu=find(u); fv=find(v);if(fu==fv) continue;ans=max(ans,1.0*(bh[fu]+bh[fv])/(tot-e[i].val));bh[fu]=max(bh[fu],bh[fv]);fa[fv]=fu;need--;}printf("%.2lf",ans);return 0;
      }
      
  • 入门OJ 2073: [Noip模拟题]古巴比伦

    一个皮皮题。

    我直接跑了个n2就过了,应该是数据水了……,

    但erge说if语句和++操作常数很小,跑108可以过!

    他的做法是:因为数据完全随机,所以当两个串的重叠部分长度小于某个值时,就可以直接跳出,

    至于小于哪个值,他说:“就自己估摸吧,我定的不能小于90%的长度。”

    ……

    代码:

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    char s1[10005],s2[10005];
    int ls1,ls2,cnt,ans; 
    void doit(char *A,int LA,char *B,int LB){for(int i=0;i<LA;i++){cnt=0;for(int j=0;j<LB&&i+j<LA;j++) if(A[i+j]==B[j]) cnt++;ans=max(ans,cnt);}
    }
    int main(){scanf("%d",&ls1); scanf(" %s",s1);scanf("%d",&ls2); scanf(" %s",s2);doit(s1,ls1,s2,ls2);doit(s2,ls2,s1,ls1);printf("%d",ans);return 0;
    }
    
  • 晚上
    • 回家了,lalala
  • End
    • 没有end,只有放假!

转载于:https://www.cnblogs.com/zj75211/p/7629216.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/268306.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Mysql之CURDATE()函数,NOW()函数,CURTIME()函数

可以看到CURDATE() 取的是年月日&#xff0c;CURTIME()取的是时分秒, NOW()取的是年月日时分秒 NOW()取的是年月日时分秒SELECTNOW();可以看到CURDATE() 取的是年月日 SELECTCURDATE();CURTIME()取的是时分秒, SELECTCURTIME();

MS SqlServer中少用但是好用的SQL语句

代码 /*-- 2010-02-26 -- 布朗-- QQ:156298979*/--with ties可以附加与排序字段相同值的多个行selecttop3withties *fromhrEmployee orderbyshortName ascsetrowcount3--设置全局变量,使每次返回的行数都为3行select*fromhrEmployee orderbyshortName ascsetrowcount0--设置全局…

解题报告:51nod 加农炮

2017-10-07 16:15:16 writer&#xff1b;pprp 题目来源&#xff1a; Codility基准时间限制&#xff1a;1 秒 空间限制&#xff1a;131072 KB 分值: 40 难度&#xff1a;4级算法题一个长度为M的正整数数组A&#xff0c;表示从左向右的地形高度。测试一种加农炮&#xff0c;炮弹平…

仅用 []()+! 就足以实现几乎任意Javascript代码

G Reader里Dexter同学的分享&#xff0c;来自sla.ckers.org的又一神作 点我测试 GReader里看不到效果的同学请自行测试下列HTML&#xff1a;<script language"javascript" type"text/javascript">([][(![][])[![]![]![]](!![][][(![][])[[]]([![]][]…

mysqldump普通账号Got error: 1044

[rootSHCTC-GAME5-151 release1]# mysqldump -h10.10.4.51 -u user -p password db_name >/tmp/db.sqlmysqldump: Got error: 1044: Access denied for user user10.%.%.% to database db_name when using LOCK TABLESmysql使用普通用户备份出现&#xff1a;[rootxok.la]# m…

HTML第四章

第四章 初识CSS 1.什么是CSS&#xff1a; CSS全称&#xff08;Cascading Style Sheet&#xff09;风格样式表(Style Sheet)它是用来进行网页风格设计的。 2.CSS的优势&#xff1a; &#xff08;1&#xff09;内容与表现分离&#xff0c;也就是使用前面学习的HTML语言制作网页&a…

javascript :得到上星期的这一天日期

javascript :得到上星期的这一天日期 这个问题在项目中很常见呢,一般的查询都会有一些默认要求,比如日期在一个星期内.那么,怎么设置默认值.看起来很简单的一个问题,其实很容易走进误区.但extjs里有很好的实现,在util目录下的Date.js文件里.可以看一看,写得非常好.这里有一个简…

简单实现顶部固定,中部自适应布局

最近在重构web导航的时候就发现一个问题&#xff0c;如何实现顶部固定&#xff0c;中部自适应的布局。 很多人会认为这很简单啊&#xff0c;顶部使用position: fixed;就可以实现。 <!DOCTYPE html> <html lang"zh"><head><meta charset"UT…

mysql查询当年年份

DATE_FORMAT(CURRENT_DATE,%Y)

asp.net通用用户初始化类,登录后初始化,随时随地可以应用

大家在做项目的时候都需要使用登录者的用户信息&#xff0c;几乎每一个页面&#xff0c;每一次操作都需要用户的信息&#xff1b;我这设计一个类&#xff0c;叫做UserSession&#xff0c;代码如下&#xff1a; 1.UserSession类&#xff1a; /// </summary>[Serializable]…

codeforces 808d

Array Division 题意&#xff1a;给一个序列&#xff0c;问将一个数调换顺序能否使得序列分为连续的2段后&#xff0c;2段的和相同&#xff1b; 思路&#xff1a;模拟&#xff0c;注意一点&#xff0c;可能第一个数就大于sum/2&#xff0c;所以要1-n模拟一遍再n-1模拟一遍&…

MySQL 执行 PROCEDURE ANALYSE 报错 ERROR 1064 (42000)

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near PROCEDURE ANALYSE() at line 1, Time: 0.000000s mysql 8.0.29已经没有 PROCEDURE ANALYSE()语法了

谷歌退出中国几成定局 谈判已谈崩

为什么80%的码农都做不了架构师&#xff1f;>>> 虽然GOOGLE之前曾自食其言&#xff0c;但在之后的谈判中无论是哪一方都十分强硬&#xff0c;毕竟中国不可能因为一个公司而改变自己的审查制度&#xff0c;哪怕是 GOOGLE也不会是个意外。 自春节前GOOGLE表示要退出中…

织梦dedecms默认网站地图sitemap.html优化

网站地图对于网站优化很重要&#xff0c;搜索引擎就是靠网站地图去收录网站页面&#xff0c;本文主要讲解优化织梦自带的网站地图功能。织梦自带的网站地图使用方法&#xff1a;织梦后台——生成——HTML更新——更新网站地图&#xff0c;可以在data目录下生成sitemap.html 。缺…

《WebForm开发系列之控件篇》Item2 ListBox

1. 属性列表&#xff1a; SelectionMode 组件中条目的选择类型&#xff0c;即多选(Multiple)、单选(Single) Rows 列表框中显示总共多少行 Selected 检测条目是否被选中 SelectedItem 返回的类型是ListItem&#xff0c;获得列表…

连接数据库的方法---ODBC

2012-12-10 11:50 (分类:计算机程序) 技术博客&#xff0c;对抗遗忘…… 1.ODBC Open Database Connectivity 1.1 简介&#xff1a;提供了一组对数据库访问的标准API&#xff08;应用程序编程接口&#xff09;&#xff0c;这些API利用SQL来完成其大部分任务。ODBC本身也提…

IDEA翻译插件Translate安装

1:安装插件 idea找到Plugins 输入Translate 点击installed 重启 2:翻译代码 选中代码&#xff0c;右键点击Translate 就能翻译了