Toph easy problem(Mixed Fractions)

Question:

Mixed Fractions

Limits: 1s, 512 MB

Given an improper fraction (as the numerator N and the denominator D), determine and print it in mixed fraction form.
Here are a few examples of improper and mixed fractions:
ImproperMixed
\frac{9}{5}1\frac{4}{5}
\frac{3}{2}1\frac{1}{2}
\frac{11}{5}2\frac{1}{5}

Input

The input will contain two integers N (1 < N < 100) and D (1 < D < N).
All test cases will always produce a valid mixed fraction.

Output

Print three integers: the whole number, the numerator and the denominator of the mixed fraction, each separated by a space.

Samples

InputOutput
9 5

Solve in C:

#include<stdio.h>
int main()
{
    int m,n,a,b,c;
    scanf("%d%d",&m,&n);
    a=m/n;
    b=m%n;
    c=n;
    printf("%d %d %d\n",a,b,c);
    return 0;

}


1 4 5

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.