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

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
আহমেদ শুভ৯৬৯

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

lightOJ 1414 - February 29

#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
map<string,int> mp;
char mon[20][25]={"January",
 "February", "March", "April",
  "May", "June", "July", "August",
   "September", "October", "November",
   "December"};
int main()
{

    for(int i=0;i<12;i++)
    mp[mon[i]]=i+1;
    int cas,T=1;
    cin >> cas;
    int y,m,t1,t2;char a[25];
    while(cas--)
    {
        scanf("%s%d,%d",a,&m,&y);
        t1=t2=0;
        if((y%400==0)||(y%100!=0&&y%4==0))
        {
            if(mp[a]>2)
            y++;
        }y--;
        t1+=(y/4-y/100+y/400);
        scanf("%s%d,%d",a,&m,&y);
        if((y%400==0)||(y%100!=0&&y%4==0))
        {
            if(mp[a]>2||(mp[a]==2&&m==29))
            y++;
        }y--;
        t2+=(y/4-y/100+y/400);
        printf("Case %d: %d\n",T++,t2-t1);
    }
    return 0;
}


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

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

lightOj 1113 - Discover the Web solve by c++

#include<iostream>
#include<stdio.h>
#define S 103
using namespace std;

string Browser[S];

int main(){
    int t, last, ind, cs = 0;
    string inp;
    cin >> t;
    while(t--){
        last = 0, ind = 0;
        Browser[last] = "http://www.lightoj.com/";
        cout << "Case " << ++cs << ":" << endl;
        while(cin >> inp){
            if(inp == "QUIT")break;
            else if(inp == "VISIT"){
                cin >> inp;
                cout << inp << endl;
                Browser[++ind] = inp;
                last = ind;
            }
            else if(inp == "FORWARD"){
                if(ind + 1 > last)puts("Ignored");
                else cout << Browser[++ind] << endl;
            }
            else if(inp == "BACK"){
                if(ind - 1 < 0)puts("Ignored");
                else cout << Browser[--ind] << endl;
            }
        }
    }
    return 0;
}


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