Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Sun999

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

Language: cpp

Time: 0.005 second

Submitted On: 2026-10-07 21:34:23

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

int main(){
	string s;
	cin>>s;
	string new_s = s;
	new_s.erase(new_s.end()-1);   
	reverse(new_s.begin(),new_s.end());
	string ans = "";
	
	
	for(int i=0; i<15; i++){
		if(i % 2 == 0){
			int temp = (new_s[i] -  '0') * 2;
			if(temp > 9){
				int c = temp%10;
				ans.push_back(c);
				int digit = temp/10;
				ans.push_back(digit);
			}
			else{
				ans.push_back(temp);
			}
			
		}
		else{
			int k = new_s[i] - '0';
			ans.push_back(k);

		}
	}
	
	
	int size = ans.length();
	int sum = 0;
	for(int i=0; i<size; i++){
		sum+=ans[i];
	}

	
	int final = (10-(sum%10))%10;
	
	if(final == s[15] - '0'){
		cout<<"yes"<<'\n';
	}
	else{
		cout<<"no"<<'\n';
	}

	
	return 0;
}