Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. /// Typedef
  5. typedef long long ll;
  6. typedef unsigned long ul;
  7. typedef unsigned long long ull;
  8. typedef vector<int> vi;
  9. typedef vector<vi> vvi;
  10. typedef vector<ll> vll;
  11. typedef pair<int,int> pii;
  12. typedef pair<ll,ll> pll;
  13. typedef vector< pii > vii;
  14.  
  15. #define pb push_back
  16. #define ppb pop_back
  17. #define MP make_pair
  18. #define ff first
  19. #define ss second
  20. #define sf scanf
  21. #define pf printf
  22. #define SQR(x) ((x)*(x))
  23. #define loop(i, y) for(int i=0; i<int(y); i++)
  24. #define FOR(i, x, y) for(int i=int(x); i<=int(y); i++)
  25. #define ROF(i, x, y) for(int i=int(x); i>=int(y); i--)
  26. #define ALL(c) c.begin(), c.end()
  27. #define SZ(c) int(c.size())
  28. #define CLR(x, y) memset(x, y, sizeof(x))
  29. #define READ(f) freopen(f, "r", stdin)
  30. #define WRITE(f) freopen(f, "w", stdout)
  31. #define FastIO ios_base::sync_with_stdio(false)
  32. #define tr(it, container) for(auto it = container.begin(); it != container.end(); it++)
  33. #define sci(x) scanf("%d", &x)
  34. #define scii(x, y) scanf("%d %d", &x, &y)
  35. #define sciii(x, y, z) scanf("%d %d %d", &x, &y, &z)
  36. #define scl(x) scanf("%lld", &x)
  37. #define scll(x, y) scanf("%lld %lld", &x, &y)
  38. #define sclll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
  39.  
  40.  
  41. /// Constants
  42. #define mx 10000007
  43. #define MOD 1000000009
  44. #define base 1000000007
  45. #define eps 1e-9
  46. #define INF 1llu<<61 // 2,305,843,009,213,693,952
  47. #define inf 1<<29 // 536,870,912
  48. #define PI acos(-1.0) // 3.1415926535897932
  49.  
  50. ll digit(ll x){
  51. ll temp=0;
  52. while(x!=0){
  53. temp+=x%10;
  54. x/=10;
  55. }
  56. return temp;
  57. }
  58.  
  59. int main()
  60. {
  61. FastIO;
  62. #ifdef online
  63. //clock_t tStart = clock();
  64. READ("input.txt");
  65. WRITE("output.txt");
  66. #endif // online
  67. ll tc;
  68. cin>>tc;
  69. cin.ignore();
  70. while(tc--){
  71. string s;
  72. ll sum=0, x, cnt=0;
  73. vll arr;
  74. getline(cin, s);
  75. for(int i=0; i<SZ(s); i++){
  76. if(s[i]!=' '){
  77. cnt++;
  78. if(cnt%2==1){
  79. x=s[i]-'0';
  80. x*=2;
  81. if(x>9)x=digit(x);
  82. arr.pb(x);
  83. }
  84. else{
  85. x=s[i]-'0';
  86. arr.pb(x);
  87. }
  88. }
  89. }
  90. sum=accumulate(arr.begin(), arr.end(),0);
  91. if(sum%10==0)cout<<"Valid"<<endl;
  92. else cout<<"Invalid"<<endl;
  93. }
  94.  
  95. #ifdef online
  96. fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  97. #endif // online
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement