AISing Programming Contest 2021(AtCoder Beginner Contest 202)

AISing Programming Contest 2021(AtCoder Beginner Contest 202)

  • A Three Dice
  • B
  • C

导读:
简单的题目,只说明题意,或者直接说明结论
下面的难题,会做详细的解释和证明

A Three Dice

给出三个色子的上面,求三个色子的地面和

int a[10];

void work()
{
  int x, y, z; cin >> x >> y >> z;

  a[1] = 6;
  a[6] = 1;
  a[3] = 4;
  a[4] = 3;
  a[2] = 5;
  a[5] = 2;

  cout << a[x] + a[y] + a[z] << endl;
 }

B

将字符串翻转,然后将9与6呼唤就可以了

void work()
{
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  int a[10];
  a[0] = 0;
  a[1] = 1;
  a[6] = 9;
  a[9] = 6;
  a[8] = 8;
  for (auto it : s)
    cout << a[it - '0'];
  cout << endl;
}

C

将a作为计数器预处理出来,b存每个数,遍历c作为b的下标记录在a中出现的次数,注意开long long

int n;
int a[N], b[N], c[N];
void work()
{
  cin >> n;
  rep(i, n){
    int x; scanf("%d", &x);
    a[x] ++;
  }
  rep(i, n) scanf("%d", &b[i]);

  LL sum = 0;
  rep(i, n) {
    int x; scanf("%d", &x);
    sum += a[b[x]];
  }

  cout << sum << "\n";
}

你可能感兴趣的:(AtCoder)