Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: angpangSK

Problemset: บาร์โค้ด

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-23 21:06:54

#include <iostream>
using namespace std;

int main() {
  string barcode;
  cin >> barcode;
  int SumEven = 0;
  int SumOdd = 0;
  for (int i = 0; i < barcode.length()-1; i++) {
    if (i % 2 == 0) {
      SumOdd += barcode[i] - '0';
    } else {
      SumEven += 3*(barcode[i] - '0');
    }
  }
  int Sum = SumEven + SumOdd;
  int check = barcode[barcode.length()-1] - '0';
  if ((Sum + check) % 10 == 0)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}