বুধবার, ১৭ ফেব্রুয়ারী, ২০১৬

lightOj 1042 - Secret Origins solve by c++

#include<iostream>
using namespace std;

int main()
{
    long int n, t, i, j;
    cin >> t;
    for(i = 1; i <= t; i++)
    {
        cin >> n;
        j = n;
        while(j++)
        {
            if(__builtin_popcount(n) != __builtin_popcount(j))
            {
              continue;
            }
            else
              cout << "Case " << i << ": " << j << endl;
              break;
        }
    }

    return 0;
}

ahmed shuvo969

মঙ্গলবার, ১৬ ফেব্রুয়ারী, ২০১৬

lightOj 1001 - Opposite Task solve by c ++

#include<iostream>
using namespace std;

int main()
{
   int a, b, n, t;
   cin >> t;
   while(t--)
   {
       cin >> n;
       a = n / 2;
       b = n - a;
       cout << a << " " << b << endl;
   }
    return 0;
}


ahmed shuvo969
আহমেদ শুভ৯৬৯ 

বৃহস্পতিবার, ১১ ফেব্রুয়ারী, ২০১৬

lightOj 1045 - Digits of Factorial solve by c++

#include<iostream>
#include<math.h>
using namespace std;
int test,p;
long i,n,b;
double f[1000010];

int main()
{
    cin >> test;
    for(i = 1; i <= 1000000; i++)
        f[i] = log((i)) + f[i-1];
    for(p = 1; p <= test; p++)
    {
        cin >> n >> b;
        cout << "Case " << p << ": " << (long)(f[n]/(f[b]-f[b-1])+1) << endl;;
    }
    return 0;
}

print number of same char of two string solve by c++

#include<iostream>
using namespace std;

int main()
{
    int n, ln = 0;
    char str[12], com[12];
    cin >> str >> com;

    for(int i = 0; str[i] != '\0'; i++)
    {
        for(int j = 0; com[j] != '\0'; j++)
        {
            if(str[i] == com[j])
                ln ++;
        }
    }
    cout << ln << endl;
    return 0;
}


Compare two string equal or not solve by c++

#include<iostream>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    if(a == b)
        cout << "yes" << endl;
    else
        cout << "Not" << endl;
    return 0;
}



রবিবার, ৭ ফেব্রুয়ারী, ২০১৬

Print the total binary one(1) of a number solve by c++

#include<iostream>
using namespace std;

int main()
{
    int n;
    cout << "Enter the number: ";
    cin >> n;
    cout << __builtin_popcount(n) << endl;
    return 0;
}


ahemd shuvo969

lightOj 1182 - Parity solve by c++

#include <iostream>
using namespace std;
int main()
 {
    int TC,tc,n;
    tc = 1;
    cin >> TC;
    while(tc<=TC) {
        cin >> n;
        if(__builtin_popcount(n)%2==0)
            cout << "Case " << tc << ": "  << "even" << endl;
        else
            cout << "Case " << tc << ": " << "odd" << endl;
           tc++;
    }
    return 0;

 }


ahmed shuvo969