রবিবার, ২০ মার্চ, ২০১৬

lightOj 1227 - Boiled Eggs solve by c++

#include<iostream>
using namespace std;

int main()
{
    int T, n, p, q, c = 0, i, w, t, arry[50];
    cin >> T;
    while(T--)
    {
        w = 0;
        t = 0;
        cin >> n >> p >> q;
        for(i = 0; i < n; i++)
            cin >> arry[i];
        for(i = 0; i < n; i++)
        {
            if(w + arry[i] <= q && t+1 <= p)
            {
                w += arry[i];
                t++;
            }
        }
         cout << "Case " << ++c << ": " <<  t << endl;
    }
    return 0;
}


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

মঙ্গলবার, ১৫ মার্চ, ২০১৬

lightOj 1249 - Chocolate Thief solve by c++

#include<iostream>
#include<string.h>
using namespace std;

int main()
{
  int a, b, c, test, k, n,l, v, max, min, i;
   char str[21], s1[21],s2[21];
   cin >> test;
   for(i = 1; i <= test; i++)
   {   cin >> n;
       cin >> str >> a >> b >> c;
       max = min = a * b * c;
       for(k = 1; k < n; k++)
       {
           cin >> str >> a >> b >> c;
           v = a * b * c;
          if (v > max) {
            strcpy (s1 , str);
            max = v;
         }
         else if (v < min) {
            strcpy (s2 , str);
            min = v;
         }
       }
       if(max == min) cout << "Case " << ": " << i << "no thief" << endl;
       else cout << "Case " << ": " << i << s1 << " took chocolate from " << s2 << endl;
   }
    return 0;
}



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

সোমবার, ৭ মার্চ, ২০১৬

Compare is tow string is same? solve by c++

#include <iostream>
#include <string>
using namespace std;

int main ()
{
  string str1 ("green apple");
  string str2 ("red apple");
  cin >> str1 >> str2;

  if (str1.compare(str2) != 0)
    cout << "No" << endl;
   else
    cout << "Yes" << endl;
  return 0;
}

শুক্রবার, ৪ মার্চ, ২০১৬

lightOj 1354 - IP Checking solve by c++

#include<iostream>
using namespace std;

int DiToBi(int n)
{
    int mul = 1, result = 0;
    while(n > 0)
    {
        result += n % 2 * mul;
        mul *= 10;
        n /= 2;
    }
    return result;
}
int main()
{
    int T, da, db, dc, dd, ba, bb, bc, bd, cas = 0;
    char cha;
    cin >> T;
    while(T--)
    {
        cin >> da >> cha >> db >> cha >> dc >> cha >> dd;
        cin >> ba >> cha >> bb >> cha >> bc >> cha >> bd;
        if( DiToBi(da) == ba && DiToBi(db) == bb && DiToBi(dc) == bc && DiToBi(dd) == bd)
             cout << "Case " << ++cas << ": " << "Yes" << endl;
        else
             cout << "Case " << ++cas << ": " << "No" << endl;
    }
    return 0;
}






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

বৃহস্পতিবার, ৩ মার্চ, ২০১৬

lightOj 1387 - Setu solve by c++

#include<iostream>
using namespace std;

int main()
{
    int tCase, nCase, t = 0, n, m, sum ;
    string s;
    cin >> tCase;
    while(tCase--)
    {
       cin >> n;
       sum = 0;
       cout << "Case "  << ++t << ":" << endl;
       while(n--)
       {
           cin >> s;
           if(s == "donate")
            {
                cin >> m;
                sum += m;
            }
           if(s == "report")
            cout << sum << endl;
       }
    }
    return 0;
}

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