2019牛客暑期多校训练营(第五场)

持续更新(菜的程度决定更新的快慢

A:digits 2

签到,输出n个n即可。

简单附代码(

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define Pair pair<int,int>
#define int long long
#define fir first
#define sec second
const double eps=1e7;
namespace fastIO{
  #define BUF_SIZE 100000
  #define OUT_SIZE 100000
  //fread->read
  bool IOerror=0;
//inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
  inline char nc(){
    static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
      if(p1==pend){
        p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);
        if(pend==p1){IOerror=1;return -1;}
      }
      return *p1++;
  }
  inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
  template<class T> inline bool read(T &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(sign)x=-x;
    return true;
  }
  inline bool read(double &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(ch=='.'){double tmp=1; ch=nc();for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');}
      if(sign)x=-x;return true;
  }
  inline bool read(char *s){
    char ch=nc();
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
    *s=0;
    return true;
  }
  inline bool read(char &c){
    for(c=nc();blank(c);c=nc());
    if(IOerror){c=-1;return false;}
    return true;
  }
  template<class T,class... U>bool read(T& h,U&... t){return read(h)&&read(t...);}
  #undef OUT_SIZE
  #undef BUF_SIZE
};using namespace fastIO;using namespace std;
const int N=1e5;
const int mod=1e9+7;


signed main(){
  int t;read(t);
  while(t--){
    int n;read(n);
    for(int i=0;i<n;i++)printf("%lld",n);
    printf("\n");
  }
  
  return 0;
}

G:subsequence 1

题意:若干组数据,每组数据给你两个字符串S,T,问S中严格大于T的子序列的个数,子序列不能有前导0;

题解:数位DP。

两种情况:

第一种是位数大于T串的只要没有前导0,那么就符合。

第二种是位数相等,则正常数位DP。

简单附代码:

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define Pair pair<int,int>
#define int long long
#define fir first
#define sec second
const double eps=1e7;
namespace fastIO{
  #define BUF_SIZE 100000
  #define OUT_SIZE 100000
  //fread->read
  bool IOerror=0;
//inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
  inline char nc(){
    static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
      if(p1==pend){
        p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);
        if(pend==p1){IOerror=1;return -1;}
      }
      return *p1++;
  }
  inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
  template<class T> inline bool read(T &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(sign)x=-x;
    return true;
  }
  inline bool read(double &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(ch=='.'){double tmp=1; ch=nc();for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');}
      if(sign)x=-x;return true;
  }
  inline bool read(char *s){
    char ch=nc();
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
    *s=0;
    return true;
  }
  inline bool read(char &c){
    for(c=nc();blank(c);c=nc());
    if(IOerror){c=-1;return false;}
    return true;
  }
  template<class T,class... U>bool read(T& h,U&... t){return read(h)&&read(t...);}
  #undef OUT_SIZE
  #undef BUF_SIZE
};using namespace fastIO;using namespace std;

const int N=3e3+5;
const int mod=998244353;

int C[N][N],dp[N][N];
char s[N],p[N];

signed main(){
  for(int i=0;i<N;i++){
    C[i][0]=1;
    for(int j=1;j<=i;j++){
      C[i][j]=(C[i][j]+C[i-1][j]+C[i-1][j-1])%mod;
    }
  }
  int t;read(t);
  while(t--){
    int n,m;read(n,m);
    read(s+1);
    read(p+1);

    dp[0][0]=1;


    long long res=0;

    for(int i=1;i<=n;i++){
      if(s[i]!='0'){
        for(int j=m;j+i<=n;j++){
          res=(res+C[n-i][j])%mod;
          //printf("%lld %lld %lld %lld\n",i,n-i,j,C[n-i][j]);
        }
      }
    }
    //printf("%lld\n",res);

    for(int i=1;i<=n;i++){
      dp[i][0]=1;
      for(int j=1;j<=m;j++){
        dp[i][j]=dp[i-1][j];
        if(s[i]==p[j])dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod;
        else if(s[i]>p[j])res=(res+dp[i-1][j-1]*C[n-i][m-j])%mod;
      }
    }
    printf("%lld\n",res);
    /*printf("0.0\n");*/
  }
  return 0;
}

I: three points 1

题解:计算几何,只有6种情况,暴力即可。

把第一个点放在(0,0),然后放第二个点,如果a<=w那么就放在x轴上,否则放在x=w的直线上,通过三角函数计算出第三点,check第三个点是否在矩形内,即可。

六种情况:(画的有点丑,不能放大看,要么歪着脑袋看,要么存到桌面用画图看,没办法,,见谅,,)

附代码;

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define Pair pair<int,int>
#define int long long
#define fir first
#define sec second
namespace fastIO{
  #define BUF_SIZE 100000
  #define OUT_SIZE 100000
  //fread->read
  bool IOerror=0;
//inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}
  inline char nc(){
    static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
      if(p1==pend){
        p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);
        if(pend==p1){IOerror=1;return -1;}
      }
      return *p1++;
  }
  inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
  template<class T> inline bool read(T &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(sign)x=-x;
    return true;
  }
  inline bool read(double &x){
    bool sign=0;char ch=nc();x=0;
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    if(ch=='-')sign=1,ch=nc();
    for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
    if(ch=='.'){double tmp=1; ch=nc();for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');}
      if(sign)x=-x;return true;
  }
  inline bool read(char *s){
    char ch=nc();
    for(;blank(ch);ch=nc());
    if(IOerror)return false;
    for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
    *s=0;
    return true;
  }
  inline bool read(char &c){
    for(c=nc();blank(c);c=nc());
    if(IOerror){c=-1;return false;}
    return true;
  }
  template<class T,class... U>bool read(T& h,U&... t){return read(h)&&read(t...);}
  #undef OUT_SIZE
  #undef BUF_SIZE
};using namespace fastIO;using namespace std;

const int N=3e3+5;
const double eps=1e-7;
const double pi=acos(-1.0);
const int mod=998244353;

struct node{
  double x,y;
}point[4];
double w,h,a,b,c;
bool check(double a,double b,double c,int one,int two,int three){
  point[one].x=0;point[one].y=0;
  if(a>w){
    point[two].x=w;
    point[two].y=sqrt(a*a-w*w);
  }
  else{
    point[two].x=a;
    point[two].y=0;
  }
  double p=acos((a*a+b*b-c*c)/(2*a*b));
  p+=atan(point[two].y/point[two].x);
  point[three].x=cos(p)*b;point[three].y=sin(p)*b;
  if(point[three].x<=w+eps && point[three].y<=h+eps && point[three].x>=-eps && point[three].y>=-eps)return 1;
  return 0;
}
void Print(){
  printf("%.12lf %.12lf %.12lf %.12lf %.12lf %.12lf\n",point[1].x,point[1].y,point[2].x,point[2].y,point[3].x,point[3].y);
}
signed main(){
  int t;read(t);
  while(t--){
    read(w,h,a,b,c);
    if(check(a,b,c,1,2,3)){Print();continue;}
    if(check(a,c,b,2,1,3)){Print();continue;}
    if(check(b,a,c,1,3,2)){Print();continue;}
    if(check(b,c,a,3,1,2)){Print();continue;}
    if(check(c,a,b,2,3,1)){Print();continue;}
    if(check(c,b,a,3,2,1)){Print();continue;}
  }
  return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值