#30604: 不是ㄟ,你不能這樣ㄋㄟ


zaqxswdce26@gmail.com (卡比獸)

學校 : 不指定學校
編號 : 192970
來源 : [49.216.222.215]
最後登入時間 :
2023-10-24 13:17:05
a159. 11743 - Credit Check -- UVa11743 | From: [220.141.64.118] | 發表日期 : 2022-05-31 17:14

 

程式碼:

 

#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    string str;
    int a,sum;
    bool one;
    
    (cin>>a).get();
    while(a--)
    {
        stringstream ss;
        getline(cin,str);
        ss<<str;
        sum=0;
        while(getline(ss,str,' '))
        {
            one=true;
            for(auto i:str)
                if(one)
                {
                    one=false;
                    for(auto j:to_string((i-48)*2))
                        sum+=j-48;
                }
                else
                {
                    one=true;
                    sum+=i-48;
                }
        }
        if(sum%10==0)
            cout<<"Valid\n";
        else
            cout<<"Invalid\n";
    }

    return 0;
}

 
ZeroJudge Forum