Do It Wrong, Get It Right
| Do It Wrong, Get It Right |
| Time Limit: 5000ms, Special Time Limit:12500ms, Memory Limit:65536KB |
| Total submit users: 7, Accepted users: 6 |
| Problem 12627 : No special judgement |
| Problem description |
| In elementary school, students learn to subtract fractions by first getting a common denominator and then subtracting the numerators. However, sometimes a student will work the problem incorrectly and still arrive at the correct answer. For example, for the problem 5 9 4 12 one can subtract the numbers in the numerator and then subtract the numbers in the denominator, simplify and get the answer. i.e.
|
| Input |
| There will be several test cases in the input. Each test case will consist of a single line with two integers, b and n (1 ≤ b,n ≤ 106) separated by a single space. The input will end with a line with two 0s. |
| Output |
| For each case, output all of the requested fractions on a single line, sorted from smallest to largest. For equivalent fractions, print the one with the smaller numerator first. Output each fraction in the form “a/m” with no spaces immediately before or after the “/”. Output a single space between fractions. Output no extra spaces, and do not separate answers with blank lines. |
| Sample Input |
9 12 12 14 4 12 0 0 |
| Sample Output |
0/24 5/20 8/16 8/8 5/4 0/28 9/21 9/7 0/24 3/18 3/6 |
| Problem Source |
| ACM ICPC Southeast USA Regional Programming Contest 2012 |
可以枚举m或者a,如果枚举a,计算m涉及到开方操作,所以比较慢,会超时;所以只能枚举m,从2*n枚举到1就可以了。
long long输入输出要用%I64d!一直用的是%lld,纠结了好久啊!!!!
#include <cstdio>
#include <cmath>
#include <cstdlib>
#define LL long long
int main(void)
{
LL b, n;
freopen("in.txt", "r", stdin);
while (~scanf("%I64d%I64d", &b, &n))
// while (~scanf("%lld%lld", &b, &n))
{
) break;
printf(*n);
*n - ;m>;m--) {
*n-m))%(n*n)==)
printf(*n-m))/(n*n),m);
}
printf("\n");
}
;
}
嗨,中村。
随机推荐
- 《BI那点儿事》META DATA(元数据)
关于数据仓库的数据,指在数据仓库建设过程中所产生的有关数据源定义,目标定义,转换规则等相关的关键数据.同时元数据还包含关于数据含义的商业信息,所有这些信息都应当妥善保存,并很好地管理.为数据仓库的发展 ...
- 火狐浏览器Firefox上DownThemAll插件
DownThemAll插件支持断点续传.多线程下载,可以大幅度提高下载速度. 在Windows平台上,要下载大量的文件,迅雷自然是首选:但在非Windows平台上,只要安装一个火狐浏览器,再安装Dow ...
- Security » Authorization » 要求处理器中的依赖注入
Dependency Injection in requirement handlers¶ 30 of 32 people found this helpful Authorization handl ...
- h.APR通道是个怎么回事
APR通道是Tomcat比较有特色的通道,在早期的JDK的NIO框架不成熟的时候,因为java的网络包的低效,Tomcat使用APR开源项目做网络IO,这样有效的缓解了java语言的不足,提供了一个高 ...
- Android驱动之JNI编写
要想用java去调用C函数接口那么就需要使用JNI(Java Native Interface,Java 本地调用)去访问本地的动态链接库. 关于NDK的安装,现在有linux环境下的版本,也有win ...
- 51nod1693 水群
题目链接:51nod1693 水群 题解参考大神的博客:http://www.cnblogs.com/fighting-to-the-end/p/5874763.html 这题时限0.4秒,真的够狠的 ...
- PHP数组去重..............过滤字段
$test_data = M('hot'); //实例化数据表 $data = $test_data->Distinct(true)->field('descriprion')->o ...
- PDF 补丁丁 0.4.2.1013 测试版发布:修复替换PDF文档字体等问题
新的测试版修复了若干问题,建议下载了旧测试版的用户更新.修复的问题列表: 替换PDF文档字体可能将字体宽度变成0. 书签编辑器在加载XML书签时不显示对应文档的预览. 自动生成书签功能复制文本筛选器后 ...
- c#网络通信框架networkcomms内核解析之十 支持优先级的自定义线程池
NetworkComms网络通信框架序言 本例基于networkcomms2.3.1开源版本 gplv3协议 如果networkcomms是一顶皇冠,那么CommsThreadPool(自定义线程池 ...
- windows系统服务编程代码示例分享
#include"XXXX.h" //包含的头文件 //定义全局函数变量 void Init(); BOOL IsInstalled(); BOOL Install(); BOOL ...

