ACdream原创群赛(12)のBUAA选拔赛

宣传下这个oj。

A

typedef long long LL  ;

const  LL mod = 1000000007LL ;
LL  c[2028][2028] ;
void Getc(){
     c[0][0] = 1 ;
     for(int i = 1 ; i < 2028 ; i++){
         c[i][0] = c[i][i] = 1 ;
         for(int j = 1 ; j < i ; j++){
             c[i][j] = (c[i-1][j] + c[i-1][j-1]) % (mod - 1) ;
         }
     }
}

LL   Pow(LL x , LL y){
     LL s = 1 ;
     for(; y ; y >>=1){
         if(y&1){
             s *= x ;
             s %= mod ;
         }
         x *= x ;
         x %= mod ;
     }
     return s ;
}

LL   answer(LL n , LL m){
     if(n == 1)  return m ;
     LL s = 1 ;
     for(LL i = 1 ; i <= m ; i++){
         s *= Pow(i , n * c[n-1+m-i-1][n-1-1] % (mod-1)) ;
         s %= mod ;
     }
     return s ;
}

int  main(){
     Getc() ;
     int t ; LL n , m ;
     cin>>t ;
     while(t--){
          scanf("%lld%lld" ,&n , &m) ;
          printf("%lld\n" , answer(n , m)) ;
     }
     return 0  ;
}


B

ACdream原创群赛(12)のBUAA选拔赛_第1张图片


D

ACdream原创群赛(12)のBUAA选拔赛_第2张图片

F

typedef long long LL ;
int  c[20] ;
int  judge(LL x){
     int  t = 0  , i ;
     while(x){
           c[t++] = x % 10 ;
           x /= 10 ;
     }
     for(i = t-1 ; i >= 1 ; i--){
          if(c[i] == 6 && c[i-1] == 1) return 1 ;
     }
     return 0 ;
}
 
const int inf = 1000000000 ;
int  dp[6200] , father[6200] ;
int  a[6200] ;
 
void  make(){
      int i ,  j  , m = 0  ;
      fill(dp , dp+6170 , inf) ;
      memset(father , -1 , sizeof(father)) ;
      for(i = 1 ; i <= 6161 ; i++){
           if(judge(i)) a[m++] = i ;
      }
      dp[0] = 0 ;
      for(i = 1 ; i <= 6161 ; i++){
          for(j = 0 ; j < m && i >= a[j] ; j++){
              if(dp[i] > dp[i - a[j]] + 1){
                   dp[i] = dp[i-a[j]] + 1 ;
                   father[i] = i - a[j] ;
              }
          }
      }
}
 
void out(int x){
     if(x){
          out(father[x]) ;
          printf(" %d" , x - father[x]) ;
     }
}
 
int  main(){
     make() ;
     int i , j , t ;
     LL n , x , y ;
     cin>>t ;
     while(t--){
           scanf("%lld" ,&n) ;
           if(judge(n))
                printf("1 %lld\n" , n) ;
           else if(n <= 6161){
                if(dp[n] == inf) printf("0") ;
                else printf("%d" , dp[n]) , out( (int)n ) ;
                puts("") ;
           }
           else{
                x = 6100 ;
                y = 61 ;
                n -= 6161 ;
                x += (n%100) ;
                y += (n/100*100) ;
                printf("2 %lld %lld\n" , x , y) ;
           }
     }
     return 0 ;
}

G

const double EPS = 1e-12 ;
double add(double a, double b){
    return (fabs(a + b) < EPS * (fabs(a) + fabs(b))) ? 0 : (a + b);
}
 
struct Point{
    double x, y;
    Point(){}
    Point(double x, double y):x(x),y(y){}
    double operator ^(Point a){
        return add(x * a.y ,- y * a.x );
    }
    Point operator - (Point a){
        return Point(add(x ,- a.x) , add(y ,- a.y)) ;
    }
    void read(){
        scanf("%lf%lf" , &x ,&y) ;
    }
};
 
struct Line{
    Point st, ed;
    Line(){}
    Line(Point st, Point ed):st(st),ed(ed){}
    bool intersection(Line l){
       double d1  = (ed -st)^(l.st - st) , d2 = (ed - st)^(l.ed - st) ;
       return d1 * d2 <= 0 ;
    }
};
 
const  int  maxn = 58 ;
Point  dot[maxn*4] ;
Line   line[maxn] ;
int    n ;
int    answer(){
       int i ,  j  , k , t  , s = 0 ;
       for(i = 1 ; i <= 2*n ; i++){
          for(j = i+1 ; j <= 2*n ; j++){
               t = 0 ;
               Line now = Line(dot[i] , dot[j]) ;
               for(k = 1 ; k <= n ; k++){
                   t += now.intersection(line[k]) ;
               }
               s = max(s , t)  ;
          }
       }
       return s  ;
}
 
int main() {
    int t , i ;
    cin>>t;
    while(t--){
        cin>>n;
        for(i = 1 ; i <= n ; i++){
           scanf("%lf%lf%lf%lf" ,&dot[i].x , &dot[i].y , &dot[i+n].x , &dot[i+n].y) ;
           line[i] = Line(dot[i] , dot[i+n]) ;
        }
        cout<< answer() << endl ;
    }
    return 0;
}



I
const int maxn = 10008 ;
int  n  , m ;
int  a[maxn] , b[maxn] , c[maxn]  , in[maxn] ;
vector<int> lis  , g[maxn] ;
 
int  judge(int t){
     int i  , s = 0 ;
     for(i = 1 ; i <= n ; i++){
          g[i].clear() ;
          in[i] = 0 ;
     }
     for(i = 1 ; i <= m ; i++){
          if(c[i] > t){
                g[b[i]].push_back(a[i]) ;
                in[a[i]]++ ;
          }
     }
     queue<int>q ;
     for(i = 1 ; i <= n ; i++){
          if(in[i] == 0)  q.push(i) ;
     }
     while(! q.empty()){
           int u = q.front() ; q.pop() ;
           s++ ;
           for(i = 0 ; i < g[u].size() ; i++){
                int v = g[u][i] ;
                if( --in[v] == 0 ) q.push(v) ;
           }
     }
     return s == n ;
}
 
int  answer(){
     sort(lis.begin() , lis.end()) ;
     int L = 0 , R = 1000000010 , M  , i  , s ;
     while(L <= R){
          M = (L + R) >> 1 ;
          if(judge(M)){
               s = M ;
               R = M - 1 ;
          }
          else L = M + 1 ;
     }
     return  s ;
}
 
int main(){
    int t ,  i ;
    cin>>t  ;
    while(t--){
         scanf("%d%d" ,&n ,&m)  ;
         lis.clear() ;
         for(i = 1 ; i <= m ; i++){
              scanf("%d%d%d" , &a[i] , &b[i] , &c[i]) ;
              lis.push_back(c[i]) ;
         }
         printf("%d\n" , answer()) ;
    }
    return 0;
}




你可能感兴趣的:(ACdream原创群赛(12)のBUAA选拔赛)