Mixed Fractions

You are part of a team developing software to help students learn basic mathematics. You are to write one part of that software, which is to display possibly improper fractions as mixed fractions. A proper fraction is one where the numerator is less than the denominator; a mixed fraction is a whole number followed by a proper fraction. For example the improper fraction 27/12 is equivalent to the mixed fraction 2 3/12. You should not reduce the fraction (i.e. don’t change 3/12 to 1/4).

Input

Input has one test case per line. Each test case contains two integers in the range [1,231−1][1,231−1]. The first number is the numerator and the second is the denominator. A line containing 0 00 0 will follow the last test case.

Output

For each test case, display the resulting mixed fraction as a whole number followed by a proper fraction, using whitespace to separate the output tokens.

Sample Input 1 Sample Output 1
27 12
2460000 98400
3 4000
0 0
2 3 / 12
25 0 / 98400
0 3 / 4000

题意

把给出的分数化成整数和真分数的形式

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
long long n, m;
while(cin >> n >> m) {
if(n == m && n == )
break;
long long cnt = ;
if(n >= m) {
cnt = n / m;
n = n - cnt * m;
}
printf("%d %d / %d\n", cnt, n, m);
}
}

Kattis - mixedfractions的更多相关文章

  1. It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)

    题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...

  2. A - Piece of Cake Kattis - pieceofcake (数学)

    题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...

  3. Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)

    题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...

  4. G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)

    题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...

  5. E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)

    题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...

  6. G - Galactic Collegiate Programming Contest Kattis - gcpc (set使用)

    题目链接: G - Galactic Collegiate Programming Contest Kattis - gcpc 题目大意:当前有n个人,一共有m次提交记录,每一次的提交包括两个数,st ...

  7. Kattis - virus【字符串】

    Kattis - virus[字符串] 题意 有一个正常的DNA序列,然后被病毒破坏.病毒可以植入一段DNA序列,这段插入DNA序列是可以删除正常DNA序列中的一个连续片段的. 简单来说就是,给你一段 ...

  8. Kattis - bank 【简单DP】

    Kattis - bank [简单DP] Description Oliver is a manager of a bank near KTH and wants to close soon. The ...

  9. City Destruction Kattis - city dp

    /** 题目:City Destruction Kattis - city 链接:https://vjudge.net/problem/Kattis-city 题意:有n个怪兽,排成一行.每个怪兽有一 ...

随机推荐

  1. forEach 列出数组的每个元素:

    数组.forEach便利所有的元素 array.forEach(function(currentValue, index, arr), thisValue) function(currentValue ...

  2. codeforce 788 A. Funtions again

    链接 A. Functions again 题意 这是一道求最大连续子序列和变形题. 做法 先将abs(a[i+1]-a[i]算出来,然后用两个数组dp[i],cp[i],dp维护其最大值,cp维护其 ...

  3. HILLSTONE sg6000 g5150 怎么恢复出厂设置

    hillstone恢复出厂设置的方法(忘记密码的情况) 口令丢失情况下的处理 如果口令丢失,用户无法登录安全路由器进行配置,请在安全路由器刚启动时按住 CLR 按键大约 5 秒,使设备恢复到出厂配置. ...

  4. 仅前端cookie之记住密码

    参考文章给忘了...,我就在他基础上修改了一些,但至于安全性,我没弄md5,所以安全系数应该为0 <!DOCTYPE html> <html lang="en"& ...

  5. Java Spring 两大特色

    0 引言 本文主要描述的是Spring常用的两大特色功能:AOP和IoC容器 1 IoC Spring的IoC:就是常说的“控制反转”,也又叫依赖注入的(DI). 优点:IoC最大的好处就是把对象生成 ...

  6. git 教程2 (git常用命令解说)

    <1>$ git -- help (调出git的帮助文档) <2>$ git +命令 --help (查看某个具体命令的帮助文档) <3>$ git --versi ...

  7. Node-Blog整套前后端学习记录

    Node-Blog 后端使用node写的一个一整套的博客系统 #### 主要功能 登录 注册 发表文章 编辑/删除文章 添加/删除/编辑文章分类 账号的管理 评论功能 ... 所用技术 node ex ...

  8. BZOJ 3774 最优选择 (最小割+二分图)

    题面传送门 题目大意:给你一个网格图,每个格子都有$a_{ij}$的代价和$b_{ij}$的回报,对于格子$ij$,想获得$b_{ij}$的回报,要么付出$a_{ij}$的代价,要么$ij$周围四联通 ...

  9. 我的第一个arcgis地图应用

    步骤: 1.设置一个基本的html文档 <!DOCTYPE html> <html> <head> <meta http-equiv="Conten ...

  10. nmon分析文件各sheet含义

    sheet名称sheet含义 SYS_SUMM系统汇总,蓝线为cpu占有率变化情况,粉线为磁盘IO的变化情况: AAA关于操作系统以及nmon本身的一些信息: BBBB系统外挂存储容量以及存储类型: ...