পৃষ্ঠাসমূহ

সোমবার, ৮ ফেব্রুয়ারি, ২০১৬

URI Online Judge | 1471 Dangerous Dive Solution



#include <iostream>
using namespace std;

int main()
{


    int n,r,person,flag;
    while(cin>>n>>r)
    {
        flag = 0;

        int track[n+1];
        for(int i = 1; i<n+1; i++)
        {
            track[i] = 0;
        }
        for(int i = 0; i<r; i++)
        {
            cin>>person;
            track[person] = 1;
        }

        for(int i = 1; i<n+1; i++)
        {
            if(track[i]==0)
            {
                cout<<i<<" ";
                flag=1;


            }
        }
        if(flag==0)
            cout<<'*';
        cout<<endl;
    }

    return 0;
}

সোমবার, ১ ফেব্রুয়ারি, ২০১৬

Jan’s LightOJ :: 1249 - Chocolate Thief Solution

1249 - Chocolate Thief
Solution in c++:



#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct student
{
string name;
int volume;
};

bool compare(student a,student b)
{
return a.volume<b.volume;

}
int main()
{

int t,n,height,width,depth;
string name;
cin>>t;
student st,stThief,stLost;
for(int i = 0; i < t; i++)
{
vector<student> Students;
cin>>n;
for(int i = 0; i<n; i++)
{
cin>>name>>height>>width>>depth;
st.name = name;
st.volume = height*width*depth;
Students.push_back(st);
}
sort(Students.begin(),Students.end(),compare);
cout<<"Case "<<i+1<<": ";
stLost = Students[0];
stThief = Students[n-1];
if(stThief.volume==stLost.volume)
cout<<"no thief"<<endl;
else
cout<<stThief.name<<" took chocolate from "<<stLost.name<<endl;

}

}


Jan’s LightOJ :: 1189 - Sum of Factorials Solution

Language: C++

#include <iostream>

using namespace std;
long long int Fact[25],ans[25];

long long int Factorial(int n)
{
int i;
long long int result = 1;
for(i = 1; i<=n; i++)
{

result*=i;

}
return result;

}

int main()
{
int n,countNumber ;
long long int m;
for(int i =0 ; i<20; i++)
{
Fact[i] = Factorial(i);
}

cin>>n;
for(int i = 0; i<n; i++)
{
countNumber = 0;

cin>>m;

for(int j = 19; j>=0&&m>0; j--)
{
if(Fact[j]<=m)
{

m-=Fact[j];
ans[countNumber] = j;
countNumber++;

}
}
cout<<"Case "<<i+1<<": ";
if(m!=0)
cout<<"impossible"<<endl;
else
{
cout<<ans[countNumber-1];
for(int k = countNumber-2; k>=0; k--)
cout<<"!+"<<ans[k];
cout<<"!"<<endl;


}

}



return 0;
}