Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: LukPorTum

Problemset: ตรวจบัตรเครดิต

Language: cpp

Time: 0.003 second

Submitted On: 2025-09-30 20:45:57

#include<bits/stdc++.h>
using namespace std;

int main(){
	string str;
	vector<int> num;
	cin>>str;
	for(int i=0;i<str.length()-1;i++){
        num.push_back(str[i]-48);
	}
    reverse(num.begin(),num.end());
    int ct=0;
	for(auto& e:num){
        
		if(ct%2==0)
        {
            e*=2;
        }//cout<<e<<" ";
        ct++;
	}
    //cout<<endl;
    for(int i=0;i<num.size();i++)
    {
        if(num[i]>=10)
        {
            int temp = num[i];
            temp %=10;
            num[i] = num[i]/10;
            num.insert(num.begin()+i+1, temp);
            i--;
        }
    }
    int sum = 0;
    for(auto e:num)
    {
        //cout<<e<<" ";
        sum+=e;
    }
    //cout<<sum<<endl;
    //cout<<<<endl;
   // cout<<endl;
   //cout<<
    if((10-(sum%10))%10 == (str[str.length()-1] - '0')){
        cout<<"yes";
    }
	else{
		cout<<"no";
	}
	return 0;
}