পৃষ্ঠাসমূহ

শুক্রবার, ২৫ ডিসেম্বর, ২০১৫

Jan's LightOJ :: Problem 1006 - Hex-a-bonacci Solution

[sourcecode language="c"]
/*****************************
* *
* Author: Md. Rana Mahmud *
* r4n4m4hmud.wordpress.com *
* *
*****************************/


#include <cstdio>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
long long data[100005];
long long a, b, c, d, e, f;
long long fn( long long n )
{
if( n == 0 ) return a;
else if( n == 1 ) return b;
else if( n == 2 ) return c;
else if( n == 3 ) return d;
else if( n == 4 ) return e;
else if( n == 5 ) return f;
else if(data[n]!=-1) return data[n];
else
{

data[n] = ( fn(n-1) + fn(n-2) + fn(n-3) + fn(n-4) + fn(n-5) + fn(n-6) )%10000007;

return data[n];
}
}
int main()
{
long long n, caseno = 0, cases;
cin>>cases;
while( cases-- )
{
memset(data,-1,sizeof(data));
cin>>a>>b>>c>>d>>e>>f>>n;
cout<<"Case "<<++caseno<<": "<<fn(n)%10000007<<endl;
}

}


[/sourcecode]

বুধবার, ১৬ ডিসেম্বর, ২০১৫

URI Online Judge | 2006 Identifying Tea Solution

[sourcecode language="c"]

/*****************************
* Author: Md. Rana Mahmud *
* r4n4m4hmud.wordpress.com *
*****************************/
#include <stdio.h>

int main()
{

int t,count = 0;
int a,b,c,d,e;
scanf("%d",&t);
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
if(a==t)
count++;
if(b==t)
count++;
if(c==t)
count++;
if(d==t)
count++;

if(e==t)
count++;
printf("%d\n",count);


return 0;
}

[/sourcecode]

মঙ্গলবার, ১৫ ডিসেম্বর, ২০১৫

URI Online Judge | 1235 Inside Out Solution

[sourcecode language="c"]


/*****************************
* Author: Md. Rana Mahmud *
* r4n4m4hmud.wordpress.com *
*****************************/

#include <iostream>

using namespace std;

int main()
{


int n;
cin>>n;
cin.ignore();
string line;
while(n-->0)
{
getline(cin,line);

for(int i = (line.length()/2)-1; i>=0; i--)
cout<<line[i];

for(int i = line.length()-1; i>=line.length()/2; i--)
cout<<line[i];
cout<<endl;




}

}

[/sourcecode]

URI Online Judge | 1218 Getline Three - Shoes Solution

[sourcecode language="c"]

/*****************************
* Author: Md. Rana Mahmud *
* r4n4m4hmud.wordpress.com *
*****************************/

#include <iostream>
#include <cstdio>
#include <sstream>
using namespace std;

int main()
{


int N,number,mShoes,fShoes,totalShoes,counter = 1,mark = 0;
string line,str;
char ch;

while(scanf("%d",&N)!=EOF)
{
mShoes = 0;
fShoes = 0;
cin.ignore();
getline(cin,line);
stringstream ss(line);

while(ss>>number>>ch)
{
if(number==N)
{
if(ch=='M')
mShoes++;
else if(ch=='F')
fShoes++;
}
}
if(mark!=0)
cout<<endl;
else
mark = 1;
printf("Caso %d:\n",counter);
counter++;
totalShoes = mShoes+fShoes;
printf("Pares Iguais: %d\n",totalShoes);
printf("F: %d\n",fShoes);
printf("M: %d\n",mShoes);


}

}


[/sourcecode]

URI Online Judge | 1217 Getline Two - Fruits Solution

[sourcecode language="c"]
#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
using namespace std;

int main()
{
int n;
cin>>n;
int day[n],kgCount,kg[n];
double cost, kgSum= 0,moneySum = 0;

string line,str;
for(int i = 0; i<n; i++)
{
kgCount = 0;
cin>>cost;
moneySum+=cost;
cin.ignore();
getline(cin,line);

stringstream ss(line);
while(ss>>str)
{
kgCount++;
kgSum++;

}
kg[i] = kgCount;
cout<<"day "<<i+1<<": "<<kgCount<<" kg"<<endl;

}
printf("%.2lf kg by day\n",kgSum/n);
printf("R$ %.2lf by day\n",moneySum/n);


}

[/sourcecode]