So Hard (水题)
题目网址:http://acm.fzu.edu.cn/problem.php?pid=2193
Problem Description
Input
Output
Sample Input
Sample Output
Hint
注意精度问题,数据保证不会有类似1.0的小数。
Source
福州大学第十二届程序设计竞赛
考虑集中特殊情况即可。
#include<iostream>
#include<algorithm>
#include <cstdio>
#define INF 0x3f3f3f3f;
using namespace std;
int gcd(int a,int b){
if(b==0) return a;
int t=a%b;
while(t!=0){
a=b;
b=t;
t=a%b;
}
return b;
}
int pow(int x){
int n=1;
for(int i=0;i<x;i++){
n*=10;
}
return n;
}
int main (){
int T;
cin>>T;
while(T--){
string str;
cin>>str;
int len=str.length();
int mark=0,n=0,pot;
for(int i=0;i<len;i++){
if( (mark==0&&str[i]=='0') )
continue;
if( str[i]=='.')
pot=i;
else{
n=n*10+str[i]-'0';
mark=1;
}
}
int y=pow(len-pot-1);
int gg=gcd(n,y);
//cout<<gg<<' '<<n<<'/'<<y<<endl;
n=n/gg,y=y/gg;
if(n==y)
cout<<1<<endl;
else if(y==1) cout<<n<<endl;
else
cout<<n<<'/'<<y<<endl;
}
return 0;
}
So Hard (水题)的更多相关文章
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- CF451B Sort the Array 水题
Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...
随机推荐
- 【性能诊断】十一、性能问题综合分析(案例2,windbg、wireshark)
[问题描述]: 前段时间有一项目反馈,常用的审批功能有时的响应较慢,多个管理员功能不定期的出现客户端无响应的状况,并且管理员功能一旦出现卡死,也会影响到普通的业务用户致使很多用户无法操作. ...
- Flex相关案例及资源搜集
Flex一些例子: http://blog.minidx.com/ 上千个Flex例子,对于学习者来说是一个庞大的资源宝库. http://fleksray.org/Flex_skin.html ht ...
- oc-类目、延展、协议
-----------------------------------------------Category-------------------------------------- 类目 是在原 ...
- Django数据库操作
刚学到Django的数据库操作,把它记录下来,方便以后查看: 在Django中定义数据库表,并使用Django提供的方法来对数据库进行操作(增.删.改.查) 1.定义3个数据库表: class Gro ...
- Python 创建函数和代码重用
1. cat func.py #!/usr/bin/python def func(): print "hello,this is a function" def func2(): ...
- asp.net和脚本获取当前的URL、IP地址
介绍一下ASP.NET取得当前页面的完整URL 的方放,icech做成了函数,直接用吧! private string GetPath() { string strPath = "http: ...
- 黄聪:WebBrowser执行和安装jQuery脚本(IEBrowse)
上一文章说明了如何让 js 脚本访问 .NET 中的类, 这次希望给大家说明一下在任意页面中安装 jQuery 脚本, 并操作页面上的元素. 其实在第一篇关于 IEBrowser 的文章当中, 已经有 ...
- windows下boost库的基本使用方法
因为boost都是使用模板的技术,所以所有代码都是写在一个.hpp头文件中.这样boost中的大部分内容是不需要编译生成相应的链接库,只需要设置下面的包含目录(或者设置一下环境变量),在源文件中包含相 ...
- sql异常
表结构 Id int UncheckedTitle nvarchar(50) CheckedValue nvarchar(1000) CheckedRemark nvarchar(1000) Chec ...
- 将博客搬至51CTO
为了统一博客文章,将文章搬至51cto个人博客