| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1405 人关注过本帖
标题:请问如何输出1/n
取消只看楼主 加入收藏
xiaohuo66
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2020-11-1
结帖率:88.89%
收藏
已结贴  问题点数:20 回复次数:2 
请问如何输出1/n
“OraOraOraOra...” It’s painful for Jotaro to repeat, also for SHP to recommend JoJo’s Bizarre Adventure series to Quasrain. To prove JoJo is fascinating, SHP wants to do it by  proving this problem is not hard for an oceanology doctor or a freshman like you.

Jotaro found for a fraction, it’s easy to work out it when the answer has limited digits, which is called finite decimal. However, for an answer like 1/3 and an answer like 33...3 (100 3s) / 100... (100 0s), it’s hard for him to tell them apart. So, he decided to let you design a program to mark the accurate answer. To make the task easy for you to understand and complete, we simplify the problem as follows: for a fraction in the form of 1/x, in which x is a positive integer, output it correctly. If you solve this problem, Quasrain will be willing to watch JoJo, which is exactly what SHP wants.
Input

Multiple test cases. Read to the end of file. Every line contains a positive integer n<=4000. Test cases are no more than 4000.
Output
Output the answer of 1/n in the following format.

For a finite decimal, output it completely without trailing zeros. For an infinite decimal, you don’t need to output it with certain constant number of digits like %.8f, %.10f, ... Please output it in the form of “0.xxxx(xxx...x)”, digits in the brackets standing for the shortest circulating part.  See sample for more detail.
Sample Input
1
3
4
9
10
28

Sample Output
1.0
0.(3)
0.25
0.(1)
0.1
0.03(571428)
Hint

Jotaro’s math is poor, but yours is better if you solve this problem.
Submit
Discuss
Time limit : 1 s
Memory limit : 512 mb
Submitted : 227
Accepted : 32
64bit Integer Format : %lld

搜索更多相关主题的帖子: the answer output problem for 
2020-11-01 15:39
xiaohuo66
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2020-11-1
收藏
得分:0 
谢谢谢谢谢谢 判断余数循环卡我 补充一下 这题还是多组数据哈哈
2020-11-02 10:49
xiaohuo66
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2020-11-1
收藏
得分:0 
谢谢 才看到 我用while写的 感谢大佬
2020-11-02 14:44
快速回复:请问如何输出1/n
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018147 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved