Posts

Showing posts from July, 2022

Java End-of-file

Image
  import  java.io.*; import  java.util.*; import  java.text.*; import  java.math.*; import  java.util.regex.*; public   class  Solution {      public   static   void  main(String[] args) {          /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */         Scanner sc =  new  Scanner(System.in);          int  i =  1 ;          while  (sc.hasNext()) {             String a = sc.nextLine();             System.out.pr...
  import java . util . * ; import java . io . * ; class Solution { public static void main ( String [] argh ){ Scanner in = new Scanner ( System . in ); int t = in . nextInt (); for ( int i = 0 ; i < t ; i ++ ){ int a = in . nextInt (); int b = in . nextInt (); int n = in . nextInt (); int c = a ; for ( int j = 0 ; j < n ; j ++ ){ c += Math . pow ( 2 , j ) * b ; System . out . printf ( "%s " , c ); } System . out . println (); } in . close (); } }

Maps-STL-C++

  i nt main () { int q , type ; cin >> q ; map < string , int > clas ; string name ; for ( int i ( 0 ), mark ; i < q ; ++ i ) { cin >> type >> name ; if ( type == 1 ){ cin >> mark ; clas [ name ] += mark ; } else if ( type == 2 ) clas . erase ( name ); else cout << clas [ name ] << " \n " ; } return 0 ; } ............................................ int  n;     cin>>n;     map< string , int >mp;      for  ( int  i =  0 ; i<n; i++) {      int  a;     cin>>a;      if  (a ==  1 ) {      int  b;      string c;      // cin>>b>>c;     cin>>b...

setmyset -- Sets in STL C++

  int main () { /* Enter your code here. Read input from STDIN. Print output to STDOUT */      int q , n , i , j , y , x ; cin >> q ; set < int > s ; for ( i = 0 ; i < q ; i ++ ) { cin >> y >> x ; if ( y == 1 ) { s . insert ( x ); } if ( y == 2 ) { s . erase ( x ); } if ( y == 3 ) { set < int >:: iterator itr = s . find ( x ); if ( itr != s . end ()) cout << "Yes" << endl ; //if (*itr == x) cout << "Yes" << endl; else cout << "No" << endl ; } } return 0 ; }