QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#221888#7606. Digital Nimucup-team180#ML 0ms0kbC++171.3kb2023-10-21 14:58:402023-10-21 14:58:40

Judging History

你现在查看的是最新测评结果

  • [2023-10-21 14:58:40]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2023-10-21 14:58:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int dp[18][163][1 << 17];
int main(){
  for (int i = 0; i < 18; i++){
    for (int j = 0; j < 163; j++){
      for (int k = 0; k < (1 << 17); k++){
        dp[i][j][k] = 0;
      }
    }
  }
  for (int i = 0; i < 163; i++){
    for (int j = 0; j < (1 << 17); j++){
      int j2 = (j << 1) & ((1 << 17) - 1);
      for (int k = 0; k < (i + 1) / 10; k++){
        if ((j >> k & 1) == 0){
          j2 |= 1;
        }
      }
      dp[1][i][j] = j2;
    }
  }
  for (int i = 2; i < 18; i++){
    for (int j = 0; j < 163 - 9; j++){
      for (int k = 0; k < 17; k++){
        int p = j;
        for (int l = 0; l < 10; l++){
          p = dp[i - 1][j + l][p];
        }
        dp[i][j][k] = p;
      }
    }
  }
  int t;
  cin >> t;
  for (int i = 0; i < t; i++){
    long long n;
    cin >> n;
    if (n % 10 != 0){
      cout << "Algosia" << endl;
    } else {
      string s = to_string(n);
      int L = s.size();
      int dsum = 0, p = (1 << 17) - 2;
      for (int j = L - 1; j >= 1; j--){
        int d = s[L - 1 - j] - '0';
        for (int k = 0; k < d; k++){
          p = dp[j][dsum][p];
          dsum++;
        }
      }
      if ((p & 1) == 0){
        cout << "Bajtek" << endl;
      } else {
        cout << "Algosia" << endl;
      }
    }
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

4
1
10
42
190

output:

Algosia
Bajtek
Algosia
Algosia

result: