Kattis - mixedfractions
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 |
---|---|
|
|
题意
把给出的分数化成整数和真分数的形式
代码
- #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的更多相关文章
- It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld (等差数列求和取模)
题目链接: D - It's a Mod, Mod, Mod, Mod World Kattis - itsamodmodmodmodworld 具体的每个参数的代表什么直接看题面就好了. AC代码: ...
- A - Piece of Cake Kattis - pieceofcake (数学)
题目链接: A - Piece of Cake Kattis - pieceofcake 题目大意:给你一个多边形,然后给你这个多边形的每个点的坐标,让你从这个n个点中选出k个点,问这个k个点形成的面 ...
- Subsequences in Substrings Kattis - subsequencesinsubstrings (暴力)
题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些 ...
- G - Intersecting Rectangles Kattis - intersectingrectangles (扫描线)(判断多个矩形相交)
题目链接: G - Intersecting Rectangles Kattis - intersectingrectangles 题目大意:给你n个矩形,每一个矩形给你这个矩形的左下角的坐标和右上角 ...
- E - Emptying the Baltic Kattis - emptyingbaltic (dijkstra堆优化)
题目链接: E - Emptying the Baltic Kattis - emptyingbaltic 题目大意:n*m的地图, 每个格子有一个海拔高度, 当海拔<0的时候有水. 现在在(x ...
- G - Galactic Collegiate Programming Contest Kattis - gcpc (set使用)
题目链接: G - Galactic Collegiate Programming Contest Kattis - gcpc 题目大意:当前有n个人,一共有m次提交记录,每一次的提交包括两个数,st ...
- Kattis - virus【字符串】
Kattis - virus[字符串] 题意 有一个正常的DNA序列,然后被病毒破坏.病毒可以植入一段DNA序列,这段插入DNA序列是可以删除正常DNA序列中的一个连续片段的. 简单来说就是,给你一段 ...
- Kattis - bank 【简单DP】
Kattis - bank [简单DP] Description Oliver is a manager of a bank near KTH and wants to close soon. The ...
- City Destruction Kattis - city dp
/** 题目:City Destruction Kattis - city 链接:https://vjudge.net/problem/Kattis-city 题意:有n个怪兽,排成一行.每个怪兽有一 ...
随机推荐
- MongoDB经典入门(1)--安装
一.前言 最近开始学习非关系型数据库MongoDB,却在博客园上找不到比较系统的教程,很多资料都要去查阅英文网站,效率比较低下.本人不才,借着自 学的机会把心得体会都记录下来,方便感兴趣的童鞋分享讨论 ...
- eclipse创建maven的ssm项目
自己接触ssm框架有一段时间了,从最早的接触新版ITOO项目的(SSM/H+Dobbu zk),再到自己近期来学习到的<淘淘商城>一个ssm框架的电商项目.用过,但是还真的没有自己搭建过, ...
- Python——Day1(笔记代码)
#print('Hello World')"""n1=input('请输入用户名:')print(n1)n2=input('请输入密码:')print(n2)" ...
- MySQL笔记4------面试问题
1.链接1:https://blog.csdn.net/derrantcm/article/details/51533885. 链接2:https://blog.csdn.net/derrantcm/ ...
- Django生命周期,FBV,CBV
一. Django生命周期 首先我们知道HTTP请求及服务端响应中传输的所有数据都是字符串,在Django中,当我们访问一个的url时,会通过路由匹配进入相应的html网页中.Django的请求生命周 ...
- nyoj14-会场安排问题
会场安排问题 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 学校的小礼堂每天都会有许多活动,有时间这些活动的计划时间会发生冲突,需要选择出一些活动进行举办.小刘的工作就 ...
- webKit 内核浏览器 源码分析
如需转载,请注明出处! WebSite: http://www.jjos.org/ 作者: 姜江 linuxemacs@gmail.com QQ: 457283 这是一篇自己写于一年前的工作文档,分享 ...
- Qt QImage与OpenCV Mat转换
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/51029382 应一个朋友的要求,整理总 ...
- java的数据的类型
1分类: 基本数据类型长度: Java中简单类型,占用字节数, 以及包装类 浮点数的默认类型是Double(8个字节) 如果想直接想一个变量赋值一个float(4个字节)要在数值后面添加f/F 如同向 ...
- CF786A - Berzerk
/* CF786A - Berzerk http://codeforces.com/contest/786/problem/A 博弈论 直接搜出NP状态图.记得要记忆化剪枝. * */ #includ ...