পৃষ্ঠাসমূহ

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

URI Online Judge | 2029 Honey Reservoir Solution



#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    double v,d,height,area;
    while(cin>>v>>d)
    {
        height = 4*v/(3.14*d*d);
        area = 3.14*d*d/4;
        cout<<fixed<<setprecision(2)<<"ALTURA = "<<height<<endl;
        cout<<fixed<<setprecision(2)<<"AREA = "<<area<<endl;

    }


}

URI Online Judge | 1921 Guilherme and His Kites Solution



#include <iostream>
using namespace std;
int main(){
    long long int n;
    cin>>n;
    cout<<n*(n-3)/2<<endl;

}

URI Online Judge | 1789 The Race of Slugs Solution

Solution:
Language:C++

#include <iostream>
using namespace std;
int main(){
    int l,maximum,num;
    while(cin>>l){
            maximum = 0;
        for(int i = 0; i<l; i++){

            cin>>num;
            if(num>maximum)
                maximum = num;

        }

        if(maximum<10)
            cout<<1<<endl;
        else if(maximum>=10&&maximum<20)
            cout<<2<<endl;
        else
            cout<<3<<endl;
    }

}


URI Online Judge | 1237 Compare Substring Solution

Solution:
Language: C++


#include <iostream>
#include <string>
#include <cstring>

using namespace std;

void lcs(string x,string y)
{


    int m = x.length();
    int n = y.length();
    int res = 0;
    for(int i = 0; i<m; i++)
        for(int j = 0; j<n ; j++)
        {
            if(x[i]==y[j])
            {
                int c = 0;
                for(int k = 0; k+i<m,k+j<n; k++)
                {
                    if(x[k+i]!=y[k+j])
                        break;
                    c++;
                }
                if(c>res)
                    res = c;
            }


        }
    cout<<res<<endl;


}

int main()
{

    string first,second;


    while(getline(cin,first)&&getline(cin,second))
    {
        lcs(first,second);
    }
    return 0;
}

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

URI Online Judge | 1566 Height Soluiton



#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    int nc;
    int n;
    cin>>nc;
    while(nc-->0)
    {
        scanf("%d",&n);
        vector<int> people(n);
        for(int i = 0; i<n; i++)
            scanf("%d",&people[i]);
        sort(people.begin(),people.end());

        for(int i = 0; i<n-1; i++)
            printf("%d ",people[i]);

        printf("%d",people[n-1]);
        printf("\n");

    }


}