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. mysql备份脚本二(带日志)

    #!/bin/bashdb_PATH='/shareSAN/mysqldata/ocs/mysql_back_wjf' #备份文件保存的路径#db_DBNAME='sz_ocs' #备份的数据库名db ...

  2. 强大的JQuery链式操作风格

    实例代码 <style type="text/css"> #menu {width: 300px;} .has_children {background:#555;co ...

  3. [tyvj-1391]走廊泼水节 最小生成树

    做克鲁斯卡尔的时候维护一个并查集即可. #include <iostream> #include <cstdio> #include <cstring> #incl ...

  4. MYSQL存储过程初步认知

    存储过程(Stored Procedure): 一组可编程的函数,是为了完成特定功能的SQL语句集,经编译创建并保存在数据库中,用户可通过指定存储过程的名字并给定参数(需要时)来调用执行. 优点:将重 ...

  5. 如何构建通用 api 中间层

    零.问题的由来 开门见山地说,这篇文章是一篇安利软文~,安利的对象就是最近搞的 tua-api. 顾名思义,这就是一款辅助获取接口数据的工具. 发请求相关的工具辣么多,那我为啥要用你呢? 理想状态下, ...

  6. Mysql学习总结(37)——Mysql Limit 分页查询优化

    select * from table LIMIT 5,10; #返回第6-15行数据 select * from table LIMIT 5; #返回前5行 select * from table ...

  7. static类型autowired 注入失败

    原代码:注入commonService对象失败 @Autowired private static CommonService commonService; public static List< ...

  8. Windows-命令窗口-强制关机命令

    Windows +R CMD  命令行窗口shutdown -s -f -t 以上参数中的-s代表关机,-f表示强制关闭所有应用程序,-t 00代表不用等待立即执行(时间以秒计算,把时间改长就变成了定 ...

  9. git常规使用的命令

    注: xxxx代表你的分支名称   1:本地新建一个分支,与远程分支关联: git branch --set-upstream-to origin/xxxx xxxx   2:创建本地分支: git ...

  10. Flex AsDoc 完整版

    Flex 生成AsDoc用的是SDK自带的asdoc.exe工具 生成AsDoc文档的方式有两种:ant或者FlashBuilder 外部配置工具 方法一:外部配置工具 新增一个外部配置工具.过程例如 ...