Friday, August 18, 2017

Challenge 5 - বৃত্ত নিয়ে ১




চল আজকে একটু ভিন্ন ধরণের সমস্যা সমাধান করি ।
ধর, তোমাকে একটি বৃত্তের ব্যসার্ধ ও দুটি জ্যা দেওয়া হল। এবারে বলা হলো যে কোন জ্যা টি কেন্দ্রের সবচেয়ে নিকটে অবস্থিত তা নির্নয় কর।  পারবে ?
চেষ্টা করে ফেলা যাক।

Problem Setter: Fahim Ahmed


Saturday, August 05, 2017

Challenge -4


টেস্ট কেস সম্পর্কে আমরা আগে জেনেছি এখন নিচের প্রব্লেম টি সল্ভ করি
#Problem setter : MC Rudra
Hello Programmers!
Welcome to Hello BGPSC.

Contents:

1. C Programming Course
2. Programming Challenge
3. Lactures
4. UVa Solutions
5. cpbook solutions
6. Codeforces Solutions
7. LightOJ Solutions

Friday, August 04, 2017

Challenge -3

টেস্ট কেইস কি ?

টেস্ট কেইস দ্বারা বোঝানো হয় যে, তোমার প্রোগ্রামটি ঠিক কত বার চালানো হবে। ব্যাপারটা আরো পরিষ্কার করে বলি।

ধরো, তোমাকে বলা হলো এমন একটি প্রোগ্রাম বানাতে , যেখানে তোমাকে দুটি সংখ্যার যোগফল বের করতে হবে । কিন্তু তোমাকে বলা হলো যে এভাবে প্রোগ্রামটিতে পাঁচ জোড়া সংখ্যা দেওয়া হবে এবং প্রত্যেক জোড়ার যোগফল একে একে প্রিন্ট করতে হবে । সেক্ষেত্রে আমারা টেস্ট কেইস ব্যবহার করে থাকি ।

এটি, সাধারণ একটি 'ফর লুপ' । প্রথমত একটি সংখ্যা ইনপুট নিতে হবে যা দ্বারা বোঝানো হয় যে প্রোগ্রামটি মোট তত বার চলবে। তারপর ১ থেকে সেই সংখ্যা পর্যন্ত একটি লুপ চালানো হয় ।

যেমনঃ

.
.
int main()
{
    scanf("%d",&t);
    for( i =1; i<=t ; i++ )
    {
         //you_code
     }
}
.
.


শিখে নিলে টেস্ট কেইস।
এবারে নিচের সমস্যাটি সমাধান কর ।
#Problem setter : MC Rudra

Thursday, August 03, 2017

প্যাসকেলের ত্রিভূজ ( ১ম পর্ব )

Pascal" triangle
গণিতের মজার কয়েকটি ধারার মধ্যে প্যাসকেলের ত্রিভূজ অন্যতম । ফরাসী বিজ্ঞানী 'ব্লেইজ প্যাসকেল' এর নামানুসারে এই ত্রিভূজের নামকরণ করা হয়।

ত্রিভুজের শুরু হয় ১ থেকে এবং ক্রমানুসারে সংখ্যাগুলির যোগফল থেকে ত্রিভূজটির বিস্তৃতি ঘটে ( উপরের চিত্রটি দেখ ) ।এই ত্রিভূজটিতে কিছু সুনির্দিষ্ট প্যাটার্ন বা ধারা লক্ষ্য করা যায়। আজ প্যাসকেলের ত্রিভূজের সেসব ধারা নিয়ে আলোচনা করা হলো।

Wednesday, August 02, 2017

Computer Programming Book by Tamim Shahriar Subeen pdf

Computer Programming Book by Tamim Shahriar Subeen pdf



If you want to learn Programming with C, you can download this book in Bangla language. This book will help you to learn the basic of C language in a proper way.This book is for anyone who love programming.


click here

কম্পিউটার প্রোগ্রামিং বই - সমস্যা ৬৩

কম্পিউটার প্রোগ্রামিং বই - সমস্যা ৬৩ 


সমস্যা পড়তে ক্লিক কর   মৌলিক সংখ্যা

সাবমিট করতে ক্লিক কর   সাবমিট (মৌলিক সংখ্যা)


Solution:

#include<cstdio>
#include<math.h>
using namespace std;
int main()
{
   

Sunday, May 14, 2017

uva online judge 11461

UVa online judge 543

UVA online judge 543

Goldbach's conjecture

Link:
https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=484 


Solution:

#include<bits/stdc++.h>
using namespace std;
#define N 1000000
int primes[N];
void Sieve()
{
    int i;
    for(i=2; i<=N; i++)
        primes[i] = 1;
    primes[0] = primes[1] = 0;

    int len = sqrt(N);
    for(i = 2; i <= len; ++i)
    {
        if(primes[i])
        {
            for( int k = i * i; k <= N; k += i )
                primes[k] = 0;
        }
    }
    primes[2] = 0;
}
int main()
{

    Sieve();

    int n,b,a;
    while(scanf("%d", &n)&&n)
    {
        for( a = 3; a < n; ++a)
        {
            if( primes[a] )
            {
                b = n - a;
                if( primes[b] )
                {
                    // printf("%d = %d + %d\n", n, a, b);
                    cout <<n<<" "<<"="<<" "<<a<<" "<<"+"<<" "<<b<<endl;
                    break;
                }
            }
        }
        if(a+b!=n)
            // printf("Goldbach's conjecture is wrong\n");
            cout <<"Goldbach's conjecture is wrong"<< endl;
    }
    return 0;
}

Friday, May 12, 2017

UVa online judge 11876 N+NOD(N)

 UVA online judge

problem:11876

N+ NOD (N)

problem link(PDF):

https://uva.onlinejudge.org/external/118/11876.pdf

 

 SOLUTION:

#include<bits/stdc++.h>
using namespace std;
bool prime[1000009];
vector<int>num;
vector<int>pr;
int binary(int a)
{
    int mid,L=0,u=num.size()-1;
    while(L<=u)
    {
        mid=(u+L)/2;
        if(a>num[mid])
            L=mid+1;
        else if(a<num[mid])
            u=mid-1;
        else return mid;
    }
   return mid;
}

Sunday, May 07, 2017

Solution to Uva problem 11530 - SMS Typing


Problem link:: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2525 



soliution :: 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    map< char,int >mp;
    int n,ans;
    string s;
    mp['a']=1,mp['b']=2,mp['c']=3,mp['d']=1,mp['e']=2,mp['f']=3,mp['g']=1,mp['h']=2,mp['i']=3,mp['j']=1,mp['k']=2,mp['l']=3,mp['m']=1;
    mp['n']=2,mp['o']=3,mp['p']=1,mp['q']=2,mp['r']=3,mp['s']=4,mp['t']=1,mp['u']=2,mp['v']=3,mp['w']=1,mp['x']=2,mp['y']=3,mp['z']=4;
    mp[' ']=1,mp['\n']=0;
    cin>>n;
    getchar();
    for(int i=0;i<n;i++)
    {
        ans=0;
        getline(cin,s);
        for(int i=0;i<s.size();i++)
        {
            ans=ans+mp[s[i]];
        }
        cout<<"Case #"<<i+1<<": "<<ans<<endl;
    }
    return 0;

}
/*this problem solution is solved with mapping if you don't know mapping then you will fail to undrstand so stay with us to know about mapping */
/* if you don't know about cin && cout put scanf instead of cin && printf instead of cout. Both works the same. */

Saturday, April 29, 2017

UVA ONLINE JUDGE 488

UVA online JUDGE 

PROBLEM:488

(TRIANGLE WAVE)

PROBLEM LINK:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=429

  1.  

    Solution:

      #include<bits/stdc++.h>  using namespace std; int main()

    {

UVA ONLINE JUDGE PROBLEM 11636

UVA ONLINE JUDGE  

PROBLEM 11636

Hello World!
 
Solution:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,j;

Friday, April 28, 2017

C Programming Course - 01


How to print?


Today we will learn how to print a program in C language. At first of the code , we have to write a header file. 

#include<stdio.h>

    here 'stdio' means 'Standers Input and Output. And ' .h ' says that it is a header file.
After that, we've to write,

int main()

     that means , from here the main program is going to be started. Then just write a second bracket and there write your program. 

UVA ONLINE JUDGE (PROBLEM: 11577)

UVA ONLINE JUDGE

(PROBLEM: 11577)



Solution::

#include<bits/stdc++.h>
using namespace std;
int
freq[30],t;
int main()
{

Monday, April 03, 2017

NCCF 2017






Registration for NCCF 2017

ICT Division of Bangladesh Government is organizing the National Children's Coding Fest 2017 (NCCF 2017) where the students aged between 5-12 years will participate. Considering the age and experience the competition will be based on SCRATCH only ; which is easy to do through a computer or smartphone. The deadline for Registration and Project Submission is April 12, 2017. We welcome you all to take part in NCCF 2017 towards building a true Digital Nation.


Codeforces 556A ( Case of Zeros and Ones )




Codeforces 556A
Case of Zeros and Ones



Problem Link:
http://codeforces.com/problemset/problem/556/A

UVa online judge  problem:11854
(EGYPT)


Problem link:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2954

Solution:

#include<stdio.h>
int main()
{

LightOJ Problem:1022 (circle in square)

LightOJ Problem :1022

Circle in Squqre


Problem link:
 http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1022

solution:

#include<stdio.h>
#include<math.h>

UVA:100(3N+1)

                    UVA ONLINE JUDGE
                       Problem:100(3N+1)



Problem link:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36

Solution:


#include<bits/stdc++.h>
using namespace std;

int main()
{

UVa 12578 (10:6:2)

The ACM-ICPC Live Archive

UVa 12578 
( 10:6:2 )


Problem Link: 



Solution:

#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{

কম্পিউটার প্রোগ্রামিং বই সমস্যা - 4


Problem Link:
http://cpbook.subeen.com/2012/11/rectangle-1.html




Solution:

Solution Link: http://paste.ubuntu.com/24305448/

#include<stdio.h>
int main()
{

কম্পিউটার প্রোগ্রামিং বই সমস্যা - 3

Computer Programming Book

- Problem 03 


Problem link:

http://cpbook.subeen.com/2012/11/count-numbers.html

Solution:

#include<stdio.h>
#include<string.h>
int main()
{

কম্পিউটার প্রোগ্রামিং বই সমস্যা - ১৪,জোড়-বিজোড়-১

link of problem::http://cpbook.subeen.com/2012/11/even-odd-1.html

জোড়-বিজোড় Programming Challenge

ইনপুট

প্রথম লাইনে একটি সংখ্যা থাকবে। সংখ্যাটির মান যত, ততটি লাইনে একটি করে পূর্ণসংখ্যা (0 থেকে 2147483647-এর মধ্যে) দেওয়া থাকবে।

আউটপুট

প্রতিটি পূর্ণসংখ্যার জন্য, সংখ্যাটি জোড় হলে even আর বিজোড় হলে odd প্রিন্ট করতে হবে।

উদাহরণ

ইনপুট:

3
100
0
1111



আউটপুট:

even
even
odd

soliution::

#include<stdio.h>
int main()
{
    int i,n,a[101];
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%2==0 && a[i]>=0)

        {
            printf("even\n");
        }

        else if(a[i]%2!=0 && a[i]>=0)

        {
            printf("odd\n");
        }
    }
    return 0;
}

Some essential functions of C & C++(সি এবং সি++ এর প্রয়োজনীয় ফাংশনসমূহ (বর্ণনা সহ))

সি এবং সি++ এর প্রয়োজনীয় ফাংশনসমূহ (বর্ণনা সহ)
  Function     Description
abs,labs,llabs     computes absolute value of an integer value
fabs     computes absolute value of a floating point value
div,ldiv,lldiv     computes the quotient and remainder of integer division
fmod     remainder of the floating point division operation
remainder     signed remainder of the division operation
remquo     signed remainder as well as the three last bits of the division operation
fma     fused multiply-add operation
fmax     larger of two floating point values
fmin     smaller of two floating point values
fdim     positive difference of two floating point values

nan,nanf,nanl     returns a not-a-number (NaN)

UVa 10394 solution (Twine Prime)



UVa 10394 solution 
( Twine Prime )


Link of Problem::
https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1335


SOLIUTION::


SOLIUTION LINK::http://paste.ubuntu.com/24305142/

#include<bits/stdc++.h>
using namespace std;
int mx = 20000007;
char mark[20000007];
void sieve()
{
 mark[0] = mark[1] = 1;           // 1 means not prime
 for(int i = 4; i<mx; i+=2) mark[i] = 1;
 for(int i = 3; i*i<mx; i+=2)
  if(mark[i]==0)                   // i is a prime number
   for(int j = i*i; j<mx; j+=i+i)
    mark[j] = 1;
}


int main()
{
    vector<int>a;
    vector<int>c;
    vector<int>d;
    long long int n;
 sieve();
 for(int l=0; l<=20000000; l++)
    {
        if(mark[l]==0)
        {
            a.push_back(l);
        }
    }
 for(int r=1;r<a.size();r++)
 {
     if((a[r])-a[r-1]==2)
     {
         c.push_back(a[r-1]);   // change
         d.push_back(a[r]);  // change
     }
 }

    while(cin>>n)
    {

        cout<<'('<<c[n-1]<<", "<<d[n-1]<<')'<<endl;
    }
    return 0;
}

Codeforces 791A ( Bear and Big Brother )


Codeforces 791A 
( Bear and Big Brother )



Problem Link:
http://codeforces.com/problemset/problem/791/A
Solution : 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,j,cnt;
    cin>>a>>b;
    cnt=0;
    for(i=1;; i++)
    {
            a=a*3;
            b=b*2;
            cnt++;

        if(a>b)
        {
            break;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

UVa 10079 ( Pizza Cutting )

The ACM-ICPC Live Archive

UVa 10079 ( Pizza Cutting )


10079 Pizza Cutting
When someone calls Ivan lazy, he claims that it is his intelligence that helps him to be so. If his
intelligence allows him to do something at less physical effort, why should he exert more? He also
claims that he always uses his brain and tries to do some work at less effort; this is not his laziness,
rather this is his intellectual smartness.
Once Ivan was asked to cut a pizza into seven pieces to distribute it among
his friends. (Size of the pieces may not be the same. In fact, his piece will be
larger than the others.) He thought a bit, and came to the conclusion that
he can cut it into seven pieces by only three straight cuts through the pizza
with a pizza knife. Accordingly, he cut the pizza in the following way (guess
which one is Ivan’s piece):
One of his friends, who never believed in Ivan’s smartness, was startled
at this intelligence. He thought, if Ivan can do it, why can’t my computer?
So he tried to do a similar (but not exactly as Ivan’s, for Ivan will criticize
him for stealing his idea) job with his computer. He wrote a program that
took the number of straight cuts one makes through the pizza, and output a number representing the

Sunday, April 02, 2017

Codeforces Problem 762A (K-th-divisor)

Codeforces Problem 762A 
(K-th-divisor)


Problem link : 
http://codeforces.com/problemset/problem/762/A

You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.
Divisor of n is any such natural number, that n can be divided by it without remainder.
Input
The first line contains two integers n and k (1 ≤ n ≤ 10151 ≤ k ≤ 109).
Output

কম্পিউটার প্রোগ্রামিং বই সমস্যা - ২


problem link::
http://cpbook.subeen.com/2012/11/positive-negative.html

soliution::
#include<stdio.h>
int main()
{
    long long int n,b,a,sum=0,total=0;

    scanf("%lld", &n);

    for(b = 1; b<=n; b++)

    {
        scanf("%lld",&a);

        if (a>=0)
        {
            total=total+1;
        }
        else if(a<0)
        {
            sum=sum+1;
        }


    }
    printf("%lld %lld\n",total,sum);
    return 0;
}

UVA Solution Prime words (10924)

  10924 Prime Words  UVA ONLINE JUDGE

#include<stdio.h>
#include<string.h>
#include<math.h>
char str[5000000];
int main()
{

    while(scanf("%s",str)!=EOF)
    {


    int a,b,c,d,e;
    a=strlen(str);
    for(c=0;c<a;c++)
    {
        if(str[c]>='a' && str[c]<='z')
        {
            str[c]=str[c]-96;
        }
       else if(str[c]>='A' && str[c]<='Z')
        {
            str[c]=str[c]-38;
        }
    }
    long long int result=0;
    for(c=0;c<a;c++)
    {
       result+=str[c];
    }

      int nil,bis=0;
      for(nil=1;nil<=sqrt(result);nil++)
      {

          if(result%nil==0)
          {
              bis++;
          }
      }
      if(bis==1)
      {
          printf("It is a prime word.\n");
      }
      else
        printf("It is not a prime word.\n");



}
return 0;
}

Fibonacci

Finding the sum of Fibonacci 
&& 
The series of Fibonacci 

soliution::

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int f[100000],i,T,j,a;

    scanf("%lld", &T);
    for(i=1; i<=T; i++)
    {
        scanf("%lld %lld", &f[0], &f[1]);
        for(j=2; j<100; j++)
        {
            f[j]=f[j-1]+f[j-2];
        }
        int z,b,sum=0;
        scanf("%lld", &b);
        scanf("%lld", &a);
        for(z=b; z<=a; z++)
        {
            sum=sum+f[z-1];
            printf(" %lld\n", f[z-1]);
        }
        printf("sum : %lld\n", sum);
    }
    return 0;
}

Divisor

Divisor Problem
soliution::
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,a,T,j,v;
    scanf("%lld",&T);
    for(i=1; i<=T; i++)
    {
        scanf("%lld", &a);
        for(j=1; j<=sqrt(a); j++)
        {
            if(a%j==0)
            {
                v=a/j;
                if(j==1)
                {
                    printf("%lld",j);
                }
                else
                {
                    printf(" %lld",j);
                }
            }
        }
        for(j=sqrt(a); j>=1; j--)
        {
            if(a%j==0)
            {
                v=a/j;
                if(v==sqrt(a))
                {

                }
                else
                {
                    printf(" %lld",v);
                }
            }
        }
        puts("");
    }
    return 0;
}

UVa Solution 10071 (Back To High School Physics)


The ACM-ICPC Live Archive

UVa 10071
(Back To High School Physics) 



Solution : 

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int v,t,i;
    for(i=1; scanf("%d %d",&v,&t)!=EOF;i++)
    {
    printf("%d\n",v*(t*2));
    }
    return 0;
}