Tuesday, May 24, 2016

Experimental Educational Round: VolBIT Formulas Blitz (J. Divisibility)


অস্থির একটা জিনিস


Let's factorize numbers from 2 to 102 = 2, 3 = 3, 4 = 22, 5 = 5, 6 = 2·3, 7 = 7, 8 = 23, 9 = 32, 10 = 2·5. If a number is divisible by all numbers from 2 to 10, its factorization should contain 2 at least in the power of 33 at least in the power of 25 and 7 at least in the power of 1. So it can be written as x·23·32·5·7 = x·2520. So any number divisible by 2520 is divisible by all numbers from 2 to 10.
There are  numbers from 1 to n divisible by all numbers from 2 to 10. In a programming language it is usually implemented as simple integer division.

Friday, May 6, 2016

My Java Learning

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package my.first.java.program;

import java.math.BigInteger;
import java.util.Scanner;
import java.math.*;
/**
 *
 * @author A K Tamzid
 */
public class MyFirstJavaProgram {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
      BigInteger a,b,c;
     
      Scanner sc= new Scanner(System.in);
      a=sc.nextBigInteger();
      //b=sc.nextBigInteger();
      //a= new BigInteger("1");
      b= new BigInteger("2");
      c=a.mod(b);
      System.out.println(c);
      if(c==a)
          System.out.println("Yes");
       


    }
   
}

Sunday, May 1, 2016

Uses of Pair


Pair : Simple Containers – The C++ Standard Template Library (STL)


Pair

The pair container is a simple container consisting of two data elements or objects. The first element is referenced as ‘first’ and the second element as ‘second’ and the order is fixed (first, second). Pair is used to combine together two values which may be different in type. Pair provides a way to store two heterogeneous objects as a single unit. Pair can be assigned, copied and compared. The array of objects allocated in a map or hash_map are of type ‘pair’ by default in which all the ‘first’ elements are unique keys associated with their ‘second’ value objects.
pair <int, char> g1;         //default
pair <int, char> g2(1, 'a');  //initialized,  different type
pair <int, int> g3(1, 10);   //initialized,  same type 
pair <int, char> g4(g3);    //copy of g3
Another way to initialize a pair is by using the make_pair() function.
g2 = make_pair(1, 'a');
To access the elements, we use variable name followed by dot operator followed by the keyword first or second.
cout << g2.first << g2.second;
Here is a C++ program that shows how pair works.
#include <iostream>
#include <utility>   //for pair
#include <string>    //for string functions
using namespace std;
int main()
{
    pair <string, int> g1;
    pair <string, int> g2("Quiz",  3);
    pair <string, int> g3(g2);
    pair <int, int> g4(5,  10);
    g1 = make_pair(string("Geeks"), 1);
    g2.first = ".com";
    g2.second = 2;
    cout << "This is pair g" << g1.second << " with the "
         << "value " << g1.first << "." << endl << endl;
    cout << "This is pair g" << g3.second
         << " with the value " << g3.first
         << ". This pair was initialized as a copy of "
         << "pair g2." << endl << endl;
    cout << "This is pair g" << g2.second
         << " with the value " << g2.first
         << ". The values of this pair were"
         << " changed after initialization."
         << endl << endl;
    cout << "This is pair g4 with values "
         << g4.first << " and " << g4.second
         << " made for showing addition. The "
         << "sum of the values in this pair is "
         << g4.first+g4.second
         << "." << endl << endl;
    cout << "We can concatenate the values of"
         << " the pairs g1,  g2 and g3 : "
         << g1.first + g3.first + g2.first << endl << endl;
    cout << "We can also swap pairs "
         << "(but type of pairs should be same) : " << endl;
    cout << "Before swapping, " << "g1 has " << g1.first
         << " and g2 has " << g2.first << endl;
    swap(g1, g2);
    cout << "After swapping, "
         << "g1 has " << g1.first << " and g2 has " << g2.first;
    return 0;
}

Speedup Android Studio

Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc...