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 |
---|---|
27 12 |
2 3 / 12 |
题意
把给出的分数化成整数和真分数的形式
代码
#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);
}
}
最新文章
- 共享MFC dULL
- linux 学习随笔-系统日常管理常用命令
- Socket.IO 1.0 正式发布,快速可靠的实时引擎
- python 练习 27
- eclipse报An error has occurred,See error log for more details. java.lang.NullPointerException错误
- setbuf
- 【Python3】SMTP发送邮件
- OpenGL入门学习(转)
- 关于 angular 小心得
- (转)安装程序发布利器——InstallShield 2011 Limited Edition
- D - Digging(01背包,贪心)
- MySQL 主从复制与读写分离概念及架构分析 (转)
- Docker镜像仓库清理的探索之路
- c#判断是否有网络
- Python sqlalchemy orm 常用操作
- KNN算法简介
- 【原创】backbone1.1.0源码解析之Events
- npm ERR! Error extracting ~/.npm/cloudant/1.9.0/package.tgz archive: ENOENT: no such file or directory, open &#39;~/.npm/cloudant/1.9.0/package.tgz&#39;
- java AES加密、解密(兼容windows和linux)
- php 备份和恢复数据库