前几天感冒了三天没怎么写题。。。今天好很多了打个三星场找点手感。

不行啊我好菜啊。只会8个。。补题的话,再说吧。G题感觉值得一补。

补了G,K不想写B不会。

说实话这个三星场还是很新人向的,知识点也蛮多(

A:

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const ll mod = 1e9+;
  5. string s,t;
  6. ll ans[];
  7. int main(){
  8. ios::sync_with_stdio(false);
  9. cin>>s>>t;
  10. int n=s.length(),m=t.length();
  11. s="*"+s;t="*"+t;
  12. ans[]=;
  13. for(int i=;i<=n;i++){
  14. for(int j=m;j>=;j--){
  15. if(s[i]==t[j]){
  16. ans[j]=(ans[j]+ans[j-])%mod;
  17. }
  18. }
  19. }
  20. cout<<ans[m]<<endl;
  21. }

B:咕咕咕

C:援圆交,注意两圆相切

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef double db;
  4. const db eps=1e-;
  5. const db pi=acos(-);
  6. int sign(db k){
  7. if (k>eps) return ; else if (k<-eps) return -; return ;
  8. }
  9. int cmp(db k1,db k2){return sign(k1-k2);}
  10. struct point{
  11. db x,y;
  12. point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
  13. point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
  14. point operator * (db k1) const{return (point){x*k1,y*k1};}
  15. point operator / (db k1) const{return (point){x/k1,y/k1};}
  16. int operator == (const point &k1) const{return cmp(x,k1.x)==&&cmp(y,k1.y)==;}
  17. bool operator < (const point k1) const{
  18. int a=cmp(x,k1.x);
  19. if (a==-) return ; else if (a==) return ; else return cmp(y,k1.y)==-;
  20. }
  21. db abs(){return sqrt(x*x+y*y);}
  22. db abs2(){return x*x+y*y;}
  23. point turn(db k1){return (point){x*cos(k1)-y*sin(k1),x*sin(k1)+y*cos(k1)};}
  24. point turn90(){return (point){-y,x};}
  25. point unit(){db w=abs(); return (point){x/w,y/w};}
  26. db dis(point k1){return ((*this)-k1).abs();}
  27. void print(){printf("%.11lf %.11lf\n",x,y);}
  28. };
  29. struct circle{
  30. point o;db r;
  31. int inside(point k){return cmp(r,o.dis(k));}
  32. };
  33. int checkposCC(circle k1,circle k2){// 返回两个圆的公切线数量
  34. if (cmp(k1.r,k2.r)==-) swap(k1,k2);
  35. db dis=k1.o.dis(k2.o); int w1=cmp(dis,k1.r+k2.r),w2=cmp(dis,k1.r-k2.r);
  36. if (w1>) return ; else if (w1==) return ; else if (w2>) return ;
  37. else if (w2==) return ; else return ;
  38. }
  39. vector<point> getCC(circle k1,circle k2){// 沿圆 k1 逆时针给出 , 相切给出两个
  40. int pd=checkposCC(k1,k2); if (pd==||pd==) return {};
  41. db a=(k2.o-k1.o).abs2(),cosA=(k1.r*k1.r+a-k2.r*k2.r)/(*k1.r*sqrt(max(a,(db)0.0)));
  42. db b=k1.r*cosA,c=sqrt(max((db)0.0,k1.r*k1.r-b*b));
  43. point k=(k2.o-k1.o).unit(),m=k1.o+k*b,del=k.turn90()*c;
  44. return {m-del,m+del};
  45. }
  46. point a,b;db d;
  47. set<point>st;
  48. int main(){
  49. //db delta = rand()/65536;
  50. scanf("%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&d);
  51. //a.turn(delta),b.turn(delta);
  52. circle x = {a,d},y={b,a.dis(b)};
  53. vector<point> s = getCC(x,y);
  54. if(s.empty()){
  55. printf("NO\n");
  56. }else{
  57. for(auto tmp:s){
  58. st.insert(tmp);
  59. }
  60. if(st.size()==){
  61. printf("NO\n");
  62. return ;
  63. }
  64. printf("YES\n");
  65. for(auto tmp:st){
  66. tmp.print();
  67. }
  68. }
  69. }

D:被这题烦死了。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,m,t;char p[];
  4. int main(){
  5. scanf("%d%d%d",&n,&m,&t);
  6. int mx1=,mn1=,mx2=,mn2=,x=,y=;
  7. for(int i=;i<=t;i++){
  8. scanf("%s",p);
  9. if(p[]=='D'){
  10. y++;
  11. }else if(p[]=='B'){
  12. x--;
  13. }else if(p[]=='C'){
  14. x++;
  15. }else if(p[]=='E'){
  16. y--;
  17. }
  18. mx1=max(mx1,x);
  19. mn1=min(mn1,x);
  20. mx2=max(mx2,y);
  21. mn2=min(mn2,y);
  22. }
  23. int h=mx2-mn2+,w=mx1-mn1+;
  24. h=m-h,w=n-w;
  25. x-=mn1,y-=mn2;
  26. printf("%d\n",(w+)*(h+));
  27. for(int i=x;i<=x+w;i++){
  28. for(int j=y;j<=y+h;j++){
  29. printf("%d %d\n",i+,j+);
  30. }
  31. }
  32. }

E:哇根本不可做啊!!!被治了四个小时啊。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int dp[][];
  4. char s[];int k;
  5. int main(){
  6. scanf("%s%d",s+,&k);
  7. int n = strlen(s+);
  8. for(int l=;l<=n;l++){
  9. for(int i=;i<=n;i++){
  10. if(i+l>n)break;
  11. dp[i][i+l]=dp[i+][i+l-]+(s[i]==s[i+l]?:);
  12. }
  13. }
  14. int ans = ;
  15. for(int i=;i<=n;i++){
  16. for(int j=i;j<=n;j++){
  17. if(dp[i][j]<=k)
  18. ans++;
  19. }
  20. }
  21. printf("%d\n",ans);
  22. }

F:最短路

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int N = 3e4+;
  5. struct Edge{int v;ll w;int nxt;};
  6. Edge e[];
  7. int head[N],cnt=;
  8. void addEdge(int u,int v,ll w){
  9. e[++cnt].v=v;
  10. e[cnt].w=w;
  11. e[cnt].nxt=head[u];
  12. head[u]=cnt;
  13. }
  14. int n,c,m;
  15. ll dis[N];
  16. struct node{
  17. ll u,d;
  18. bool operator <(const node&rhs) const{
  19. return d>rhs.d;
  20. }
  21. };
  22. void Dijkstra(){
  23. for(int i=;i<=n;i++)dis[i]=1e18;
  24. dis[]=;
  25. priority_queue<node> Q;
  26. Q.push((node){,});
  27. while (!Q.empty()){
  28. node fr = Q.top();Q.pop();
  29. ll u = fr.u,d=fr.d;
  30. if(d>dis[u])continue;
  31. for(int i=head[u];i;i=e[i].nxt){
  32. ll v=e[i].v,w=e[i].w;
  33. if(dis[u]+w<dis[v]) {
  34. dis[v] = dis[u] + w;
  35. Q.push((node) {v, dis[v]});
  36. }
  37. }
  38. }
  39. }
  40. ll t,k,p,vis[N],x,y,z;
  41. int main(){
  42. ios::sync_with_stdio(false);
  43. cin>>n>>m>>t>>k>>p;
  44. for(int i=;i<=p;i++){
  45. cin>>x;vis[x]=;
  46. }
  47. for(int i=;i<=m;i++){
  48. cin>>x>>y>>z;
  49. if(vis[y])addEdge(x,y,z*+k);
  50. else addEdge(x,y,z*);
  51. }
  52. Dijkstra();
  53. if(dis[n]<=t*){
  54. cout<<dis[n]<<endl;
  55. }else{
  56. cout<<-<<endl;
  57. }
  58. }

G:没看懂样例。

考虑主人坐在0号位置,然后我们枚举第一个人坐在哪。那么剩下的就相当于res个凳子放c-1个人每两个人中间至少有r个凳子。

去年青岛有个一样的。学长讲过但是我当时记不清了。。。 我们先把凳子放好,然后就变成 剩下的凳子放入c个桶里了。

注意会爆int和数组开两倍。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int N = 1e5+;
  5. const ll mod = 1e9+;
  6. ll up[N<<],inv[N<<],down[N<<];
  7. void init(){
  8. up[]=;
  9. for(int i=;i<=;i++){
  10. up[i]=up[i-]*i%mod;
  11. }
  12. inv[]=;
  13. for(int i=;i<=;i++){
  14. inv[i]=(mod-mod/i)*inv[mod%i]%mod;
  15. }
  16. down[]=;
  17. for(int i=;i<=;i++){
  18. down[i]=down[i-]*inv[i]%mod;
  19. }
  20. }
  21. ll C(ll x,ll y){
  22. return up[x]*down[y]%mod*down[x-y]%mod;
  23. }
  24. int n,c,r;
  25. int main(){
  26. init();
  27. scanf("%d%d%d",&n,&c,&r);
  28. ll ans = ;
  29. for(int i=;i<n;i++){
  30. ll res = n--(i+r+)+;
  31. res+=min(,i-r);
  32. res-=1ll*r*(c-);
  33. res-=c-;
  34. if(res<)continue;
  35. ans=(ans+C(res+c-,c-))%mod;
  36. }
  37. ans=ans*n%mod;
  38. if(ans) cout<<ans<<endl;
  39. else cout<<-<<endl;
  40. }

H:又一个最短路。。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 1e5+;
  4. struct Edge{int v,w,nxt;};
  5. Edge e[N*];
  6. int head[N],cnt=;
  7. void addEdge(int u,int v,int w){
  8. e[++cnt].v=v;
  9. e[cnt].w=w;
  10. e[cnt].nxt=head[u];
  11. head[u]=cnt;
  12. }
  13. int n,c,m;
  14. int dis[N],vis[N];
  15. struct node{
  16. int u,d;
  17. bool operator <(const node&rhs) const{
  18. return d>rhs.d;
  19. }
  20. };
  21. void Dijkstra(){
  22. for(int i=;i<=n;i++)dis[i]=1e8;
  23. dis[]=vis[];
  24. priority_queue<node> Q;
  25. Q.push((node){,vis[]});
  26. while (!Q.empty()){
  27. node fr = Q.top();Q.pop();
  28. int u = fr.u,d=fr.d;
  29. if(d>dis[u])continue;
  30. for(int i=head[u];i;i=e[i].nxt){
  31. int v=e[i].v,w=e[i].w;
  32. if(dis[u]+w<dis[v]) {
  33. dis[v] = dis[u] + w;
  34. Q.push((node) {v, dis[v]});
  35. }
  36. }
  37. }
  38. }
  39. int main(){
  40. ios::sync_with_stdio(false);
  41. cin>>n>>c>>m;int x,y;
  42. for(int i=;i<=c;i++){
  43. cin>>x;vis[x]=;
  44. }
  45. for(int i=;i<=m;i++){
  46. cin>>x>>y;
  47. if(vis[y])addEdge(x,y,);
  48. else addEdge(x,y,);
  49. }
  50. Dijkstra();
  51. cout<<dis[n]<<' ';
  52. for(int i=;i<=cnt;i++){
  53. e[i].w=-e[i].w;
  54. }
  55. vis[]=-vis[];
  56. Dijkstra();
  57. cout<<-dis[n];
  58. }

I:显然是矩阵快速幂。瞎搞一番一千点!之后猛然发现,,你根本不用构造矩阵,给你的就是吧。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const ll mod = 1e9+;
  5. void exgcd(ll a,ll b,ll& d,ll& x,ll& y) {
  6. if (!b) {
  7. d = a;
  8. x = ;
  9. y = ;
  10. } else {
  11. exgcd(b, a % b, d, y, x);
  12. y -= x * (a / b);
  13. }
  14. }
  15. ll inv(ll a, ll p) {
  16. ll d, x, y;
  17. exgcd(a, p, d, x, y);
  18. return d == ? (x+p)%p : -;
  19. }
  20. int n,k;
  21. struct mat{
  22. ll v[][];
  23. mat(){
  24. memset(v,, sizeof(v));
  25. }
  26. };
  27. mat mul(mat &a,mat &b){
  28. mat c;
  29. for(int i=;i<n;i++){
  30. for(int j=;j<n;j++){
  31. for(int k=;k<n;k++){
  32. c.v[i][j] = (c.v[i][j]+a.v[i][k]*b.v[k][j])%mod;
  33. }
  34. }
  35. }
  36. return c;
  37. }
  38. mat pow(mat a, int x){
  39. mat b;
  40. for(int i=;i<n;i++)
  41. b.v[i][i]=;
  42. while (x>){
  43. if(x&)
  44. b = mul(b,a);
  45. a = mul(a,a);
  46. x>>=;
  47. }
  48. return b;
  49. }
  50. int main(){
  51. scanf("%d%d",&n,&k);
  52. mat a;ll tmp;
  53. for(int i=;i<n;i++){
  54. for(int j=;j<n;j++){
  55. scanf("%lld",&tmp);
  56. tmp = tmp*inv(,mod)%mod;
  57. a.v[i][j]=tmp;
  58. }
  59. }
  60. mat b = pow(a,k);
  61. ll ans = ;
  62. for(int i=;i<n;i++){
  63. ans=(ans+1ll*(i+)*b.v[][i])%mod;
  64. }
  65. printf("%lld\n",ans);
  66. }

J:二分,然后我们找c最小的。nlognlogn竟然这么快么。。。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. struct Node{
  5. ll a,b,c;
  6. bool operator <(const Node &t)const {
  7. return c>t.c;
  8. }
  9. }p[];
  10. int n;ll k;
  11. bool check(ll x,ll k){
  12. priority_queue<Node> q;
  13. for(int i=;i<=n;i++){
  14. if(p[i].a<x)q.push(p[i]);
  15. }
  16. for(int i=;i<=n;i++){
  17. if(p[i].a>x){
  18. ll tmp = p[i].a,all=;
  19. while (tmp>x&&!q.empty()){
  20. Node y = q.top();q.pop();
  21. if(tmp-x>=x-y.a){
  22. tmp-=(x-y.a);
  23. all+=(x-y.a)*(p[i].b+y.c);
  24. }else{
  25. y.a+=(tmp-x);
  26. all+=(tmp-x)*(p[i].b+y.c);
  27. tmp=x;
  28. q.push(y);
  29. }
  30. }
  31. k-=all;
  32. if(tmp>x||k<)return false;
  33. }
  34. }
  35. return true;
  36. }
  37. int main(){
  38. ios::sync_with_stdio(false);
  39. cin>>n>>k;
  40. ll sum = ,mx=;
  41. for(int i=;i<=n;i++){
  42. cin>>p[i].a>>p[i].b>>p[i].c;
  43. sum+=p[i].a;mx=max(mx,p[i].a);
  44. }
  45. ll l=sum/n,r=mx,ans;
  46. while (l<=r){
  47. ll mid = l+r>>;
  48. if(check(mid,k)){
  49. r=mid-;
  50. ans=mid;
  51. }else{
  52. l=mid+;
  53. }
  54. }
  55. cout<<ans<<endl;
  56. }
  57. /**
  58. 5 2
  59. 5 3 8
  60. 2 8 3
  61. 3 2 4
  62. 7 2 1
  63. 6 1 1
  64.  
  65. */

K:对字符串一窍不通。反正队友什么都会

gym 101628的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. #2018-2019-2-20175204 张湲祯 实验一 《Java开发环境的熟悉》实验报告

    2018-2019-2-20175204 张湲祯 实验一 <Java开发环境的熟悉>实验报告 一.实验内容及步骤 一.使用JDK编译.运行简单的Java程序 1.输入cd zyz命令进入z ...

  2. Codeforces 558E A Simple Task (计数排序&&线段树优化)

    题目链接:http://codeforces.com/contest/558/problem/E E. A Simple Task time limit per test5 seconds memor ...

  3. margin:auto你真的理解么?

    含义 margin:auto是具有强烈计算意味的关键字,用来计算元素对应方向应该获得的剩余空间大小 填充规则 (1) 如果一侧定值,一侧auto,则auto为剩余空间大小 (2) 如果两侧均是auto ...

  4. Xamarin Layout属性(转)

    第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android: ...

  5. 生活日历NABCD需求分析

    这次我们团队要开发一个生活日历APP,对于这个APP的NABCD的需求分析,我对此作出其中的一小部分介绍. N(Need)需求 目前市场上有很多的日历程序,每个手机自带的功能中必然有日历程序.但是对于 ...

  6. SpringBoot 整合 Redis缓存

    在我们的日常项目开发过程中缓存是无处不在的,因为它可以极大的提高系统的访问速度,关于缓存的框架也种类繁多,今天主要介绍的是使用现在非常流行的NoSQL数据库(Redis)来实现我们的缓存需求. Spr ...

  7. Dubbo序列化多个CopyOnWriteArrayList对象变成同一对象的一个大坑!!

    环境: win10 + jdk 1.8 + dubbo 2.5.10 问题描述: 当一个对象(此对象内包含多个CopyOnWriteArrayList对象) 作为参数调用RPC接口后, 服务提供者拿到 ...

  8. 末学者笔记--shell编程上 1 玄

    Shell 编程 [内容简列]: 1.shell简介 2. shell分类 3. 查看shell 4. 第一个shell脚本 5. shell编程常用命令 5.1 grep 5.2 cut 5.3 s ...

  9. 编译问题解决:LINK : fatal error LNK1104: 无法打开文件“*.dll”

    一.引言 编译项目的时候,总会遇到些奇怪的问题,比如说以下这种: LINK : fatal error LNK1104: 无法打开文件“..\bin\ICPRegistration.dll” 我在编译 ...

  10. 使用X509Certificate2类操作证书文件

    public class CertHelper { string pfxPath = @"E:\开发辅助项目\cert\taisuyuanqing.pfx"; string cer ...