交大OJ 1240
来源:互联网 发布:比赛计时器软件 编辑:程序博客网 时间:2024/04/29 05:28
Description
Given a fraction m/n, where m and n are both positive integer. As you know, we can disassemble it into Finite Simple CF, that is <x0, x1,x2,…, xn > ,where n is limited.
Your job is to express m/n.
这题没啥难的,难能可贵的是我 runtime error了8次。。
下面总结下RE的情况:
1、数组开小了,或者越界了。
2、数字超过int类型
3、出现了除 0的情况 (此题就是这么错的!!)
贴下错误代码:
#include<stdio.h>long long a[10005]; int main(){ long long m,n,x,i,t,num; while(~scanf("%lld%lld",&n,&m)) { num=0; while(1) { x=n/m; a[num++]=x; n=n%m; // 如果n=4,m=2,那么出现n=0的情况,交换后m=0,然后 x=n/m=n/0,就RE了 t=n;n=m;m=t; if(n%m==0) {a[num++]=n/m; break;} } for(i=0;i<num;i++) if(i!=num-1) printf("%lld ",a[i]); else printf("%lld\n",a[i]); } return 0;}
- 交大OJ 1240
- 交大OJ 2113题
- 交大OJ 1235: 或运算
- 交大OJ 1760 Higher Mathematics
- 五月第二周 题解 交大OJ
- 交大oj-1009-二哥炒股票 C++ 总结
- 交大OJ 3002 去重归并排序
- 交大OJ 3021 有限背包(背包问题
- 交大oj-1012-增长率问题 C++ 总结
- 交大OJ 求素数个数 1783和 2110
- 交大oj-1008-二哥买期货 C++ 总结
- 交大OJ 1272 写数游戏/背包问题
- 交大oj-1022-Fib数列 C++ 解题报告
- 交大OJ 1069 二哥的硬币(多重背包/单调队列)
- 交大OJ 1602 归并排序分解:合并两个已经排好序的数列
- 交大OJ 1013 无限背包(0-1背包) 错解分析&&正解
- 交大1102
- 交大1093
- chap5 Ogre Scene Management
- 关联子查询(重点)
- RHEL 5下配置Hadoop集群:java.net.NoRouteToHostException: No route to host问题的解决
- chap6_1 Sphere Environmental mapping in OGRE
- hadoop datanode 问题 INFO org.apache.hadoop.ipc.RPC: Server at /:9000 not available yet, Zzzzz..
- 交大OJ 1240
- SSO(Single Sign-on) in Action
- poj2457(Dijkstra+priory-_queue)
- [2013.7.20] 工作and生活日志
- poj3268--dijkstra算法的灵活应用
- C语言三角函数使用时注意用的是弧度而不是角度
- 正则表达式中环视的一个简单示例
- 过滤html标签 RemoveHTML(string html)
- 《重构》读书笔记(十一)——第十一章 处理概括关系