Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- /// Typedef
- typedef long long ll;
- typedef unsigned long ul;
- typedef unsigned long long ull;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef vector<ll> vll;
- typedef pair<int,int> pii;
- typedef pair<ll,ll> pll;
- typedef vector< pii > vii;
- #define pb push_back
- #define ppb pop_back
- #define MP make_pair
- #define ff first
- #define ss second
- #define sf scanf
- #define pf printf
- #define SQR(x) ((x)*(x))
- #define loop(i, y) for(int i=0; i<int(y); i++)
- #define FOR(i, x, y) for(int i=int(x); i<=int(y); i++)
- #define ROF(i, x, y) for(int i=int(x); i>=int(y); i--)
- #define ALL(c) c.begin(), c.end()
- #define SZ(c) int(c.size())
- #define CLR(x, y) memset(x, y, sizeof(x))
- #define READ(f) freopen(f, "r", stdin)
- #define WRITE(f) freopen(f, "w", stdout)
- #define FastIO ios_base::sync_with_stdio(false)
- #define tr(it, container) for(auto it = container.begin(); it != container.end(); it++)
- #define sci(x) scanf("%d", &x)
- #define scii(x, y) scanf("%d %d", &x, &y)
- #define sciii(x, y, z) scanf("%d %d %d", &x, &y, &z)
- #define scl(x) scanf("%lld", &x)
- #define scll(x, y) scanf("%lld %lld", &x, &y)
- #define sclll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
- /// Constants
- #define mx 10000007
- #define MOD 1000000009
- #define base 1000000007
- #define eps 1e-9
- #define INF 1llu<<61 // 2,305,843,009,213,693,952
- #define inf 1<<29 // 536,870,912
- #define PI acos(-1.0) // 3.1415926535897932
- ll digit(ll x){
- ll temp=0;
- while(x!=0){
- temp+=x%10;
- x/=10;
- }
- return temp;
- }
- int main()
- {
- FastIO;
- #ifdef online
- //clock_t tStart = clock();
- READ("input.txt");
- WRITE("output.txt");
- #endif // online
- ll tc;
- cin>>tc;
- cin.ignore();
- while(tc--){
- string s;
- ll sum=0, x, cnt=0;
- vll arr;
- getline(cin, s);
- for(int i=0; i<SZ(s); i++){
- if(s[i]!=' '){
- cnt++;
- if(cnt%2==1){
- x=s[i]-'0';
- x*=2;
- if(x>9)x=digit(x);
- arr.pb(x);
- }
- else{
- x=s[i]-'0';
- arr.pb(x);
- }
- }
- }
- sum=accumulate(arr.begin(), arr.end(),0);
- if(sum%10==0)cout<<"Valid"<<endl;
- else cout<<"Invalid"<<endl;
- }
- #ifdef online
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif // online
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement