Codeforces Beta Round #7

简介: 点击打开链接 A #include#include#include#includeusing namespace std;#define N 8char G[N][N];int main(){ while(s...

点击打开链接


A

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define N 8

char G[N][N];


int main(){
  while(scanf("%s" , G[0]) != EOF){
     for(int i = 1 ; i < 8 ; i++)
         scanf("%s", G[i]);
     int ans , i , j;
     ans = 0;
     for(i = 0 ; i < 8 ; i++){
        for(j = 0 ; j < 8 ; j++){
           if(G[i][j] == 'W')
              break;
        }
        if(j == 8)
          ans++;
        for(j = 0 ; j < 8 ; j++){
          if(G[j][i] == 'W')
            break;
        }
        if(j == 8)
          ans++;
     }
     printf("%d\n" , ans == 16 ? 8 : ans);
  }
  return 0;
}


B

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;

#define MAXN 110

int t , m , pos;
int vis[MAXN];
int mark[MAXN];

bool judge(int x){
   int i , j;
   for(i = 1 ; i <= m ; i++){
     if(!vis[i]){
       for(j = i ; j < i+x && j <= m ; j++){
          if(vis[j])
            break;
       }
       if(j == i+x){
         for(j = i ; j < i+x ; j++)
            vis[j] = pos;
         return true;
       }
     }
  }
  return false;
}

void solve_erase(int x){
   for(int i = 1 ; i <= m ; i++){
     if(vis[i] == x){
       vis[i] = 0;
     }
   }
}

void solve_defragment(){
   int i , j;
   i = 1 , j = 1;
   for(; i <= m ; i++){
     if(vis[i])
       vis[j++] = vis[i];
   }
   for(; j <= m ; j++)
      vis[j] = 0;
}

int main(){
  char words[MAXN];
  int num;
  while(scanf("%d%d" , &t , &m) != EOF){
     memset(vis , 0 , sizeof(vis));
     memset(mark , 0 , sizeof(mark));
     pos = 1;
     for(int i = 0 ; i < t ; i++){
        scanf("%s" , words);
        if(strcmp(words , "defragment") != 0)
           scanf("%d" , &num);
        if(!strcmp(words , "alloc")){
           if(judge(num)){
              mark[pos] = 1;
              printf("%d\n" , pos++);
           }
           else
              printf("NULL\n");
        }
        if(!strcmp(words , "erase")){
           if(num >= pos || num <= 0 || !mark[num]){
             printf("ILLEGAL_ERASE_ARGUMENT\n");
           }
           else{
             solve_erase(num);
             mark[num] = 0;
           }
        }
        if(!strcmp(words , "defragment"))
           solve_defragment();
     }
  }
  return 0;
}



C

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;

typedef long long int64;

void gcd(int64 a , int64 b , int64 &d , int64 &x , int64 &y){
    if(!b){
      d = a;
      x = 1;
      y = 0;
    }
    else{
      gcd(b , a%b , d , y , x);
      y -= x*(a/b);
    }
}

int main(){
   int64 a , b , c , d , x , y;
   while(cin>>a>>b>>c){
        gcd(a , b , d , x , y);
        if(c%d != 0)
          printf("-1\n");
        else{
          int64 tmp = (-c)/d;
          x *= tmp , y *= tmp;
          cout<<x<<" "<<y<<endl;
        }
   }
   return 0;
}








目录
相关文章
Codeforces Round #628 解补题报告
Codeforces Round #628 解补题报告
79 0
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output ...
1245 0
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output...
1316 0
|
人工智能
Codeforces Beta Round #2 A,B,C
A. Winner time limit per test:1 second memory limit per test:64 megabytes input:standard input output:standard output ...
1235 0
|
Perl
Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard ...
915 0
|
机器学习/深度学习 Java Go
Codeforces Beta Round #1
点击打开链接 A #include #include using namespace std; long long n , m , a; int main(){ long long sum; while(cin>>...
923 0