Posts

Showing posts with the label easy

CodeChef::VOTERS

 #include <bits/stdc++.h> using namespace std ; #define boost ios::sync_with_stdio(0);cin.tie(0) #define ll long long int main(){ boost ; ll n1,n2,n3,n ; cin >> n1 >> n2 >> n3 ; n = n1+n2+n3 ; ll arr[n]; for(ll i = 0; i < n ; i++){     cin >> arr[i] ; } vector <ll> v ; ll count{1},first_elmt; sort(arr,arr+n); first_elmt = arr[0]; for(ll i =1;i<n;i++){     if(first_elmt == arr[i]){         count ++ ;     }     else{         if(count >= 2)         {             v.push_back(first_elmt);         }         first_elmt = arr[i];         count = 1;     } } cout << v.size() << '\n' ; for(ll i = 0;i...

CodeChef::CSUB

  #include   <bits/stdc++.h> using  namespace   std  ; #define   boost   ios :: sync_with_stdio ( 0 ); cin . tie ( 0 ) #define   ll  long long  int   main  (){      boost  ;      ll   t  ;      cin   >>   t  ;      while  ( t --)     {        ll   n  ;        cin   >>   n  ;        string   seq  ;        cin   >>   seq  ;        ll   count { 0 };        for  ( int   i  =  0 ;  i  <  seq . size ();  i ++){            if  ( seq [ i ]  ==...

CodeChef::KOL15A

  #include <bits/stdc++.h> using namespace std ; int main (){ int t ; cin >> t ; while (t--){ string s ; cin >> s ; int sum{ 0 } ; for ( int i = 0 ; s [ i ] ; ++i) { if ( '0' <= s [ i ] && s [ i ] <= '9' ){ sum = sum + s [ i ] - '0' ; } } cout << sum << ' \n ' ; } return 0 ; }

CodeChef::NUM239

  #include <bits/stdc++.h> using namespace std ; int main (){ int t ; cin >> t ; while (t--){ int left ; int right ; cin >> left >> right ; int full_array[right - left + 1 ] ; for ( int i = 0 ; i < right - left + 1 ; ++i) { full_array[i] = i + left ; } int count { 0 } ; for ( int i = 0 ; i < right - left + 1 ; ++i) { if (full_array[i] % 10 == 2 or full_array[i] % 10 == 3 or full_array[i] % 10 == 9 ){ count ++ ; } } cout << count << ' \n ' ; } return 0 ; }