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;
}

Codeforces 749A (Bachgold Problem)


Codeforces 749A (Bachgold Problem)



time limit per test-
1 second

memory limit per test-
256 megabytes

input-
standard input

output-
standard output
Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divisors — 1 and k.

UVa Solution 11547 - Automatic Answer


The ACM-ICPC Live Archive

                

                

            11547 - Automatic Answer





Solution : 

#include<bits/stdc++.h>
using namespace std;
int main( )
{
    int n,t,res;
    cin>>t ;
    for (int i=1;i<=t;i++)
    {
        cin>>n;
        res=((((((n*567)/9)+7492)*235)/47)-498);
        cout<<abs((res/10)%10)<<endl;
    }
    return 0;
}


Prime Words UVa 10924 problem




problem link::
https://uva.onlinejudge.org/external/109/10924.pdf




solution::

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    while(cin>>str)
    {
        long long int c=0,sum=0;
        for(int i=0;i<str.size();i++)
        {
            if(islower(str[i]))
            {
                sum+=(str[i]-'a')+1;
            }
            else
            {
                sum+=(str[i]-'A')+27;
            }
        }
        for(int j=2;j<=sqrt(sum);j++)
        {
            if(sum%j==0)
            {
                c=1;
                break;
            }
        }
        if(c==1)
        {
            cout<<"It is not a prime word."<<endl;
        }
        else
        {
            cout<<"It is a prime word."<<endl;
        }
    }
    return 0;
}

UVa Problem Solution 11462



UVa Problem 11462
Age Sort

Problem link:
https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2457



Solution : 


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

int main()
{
    long int a[2000005],i,n;
    while (scanf("%ld",&n)!=EOF)
    {
        if (n==0)
        {
            break;
        }
        for (i=0;i<n;i++)
        {
            scanf("%ld",&a[i]);
        }
        sort(a,a+n);
        for (i=0;i<n;i++)
        {
            printf("%ld",a[i]);
            if (i<(n-1))
                printf(" ");
        }
        printf("\n");
    }
    return 0;
}