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 ...
随机推荐
- 如何破解海蜘蛛ISP6.1.5 极其isp运营商 v6.1.5
海蜘蛛ISPV6.1.5,目前破解版本中最稳定的!破解步骤如下:一.安装完毕进控制台二.使用muddyboot登陆 密码(123456)三.输入root回车四.输入regtools回车五.在web控制 ...
- 项目中提示找不到class,跟命名规则有关系RulesConfigDao
项目中提示找不到class,跟命名规则有关系RulesConfigDao,而非Mapper!
- spring配置中,properties文件以及xml文件配置问题
spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件 ...
- My second "last working day"
时间真快,转眼硕士毕业已经快8年了. 今天是我的第二个last working day.也是我即将结束在外企工作的节点. 说来,毕业的时候,找工作,在确定了最后要去的单位之前,手头已经拿过了10家单位 ...
- [转]Linux环境下查看线程数的几种方法
1.cat /proc/${pid}/status 2.pstree -p ${pid} 3.top -p ${pid} 再按H,或者直接输入 top -bH -d 3 -p ${pid} top ...
- SPOJ #692. Fruit Farm
Another palindrome related problem. Actually nothing too theoretical here, but please keep following ...
- 基于SpringMVC下的Rest服务框架搭建【1、集成Swagger】
基于SpringMVC下的Rest服务框架搭建[1.集成Swagger] 1.需求背景 SpringMVC本身就可以开发出基于rest风格的服务,通过简单的配置,即可快速开发出一个可供客户端调用的re ...
- Saltstack系列3:Saltstack常用模块及API
说明 salt '*' sys.list_modules #列出当前版本支持的模块 API原理是通过调用master client模块,实例化一个LocalClient对象,再调用cmd()方法来实现 ...
- sublime text2 css格式化插件
插件下载地址:https://gist.github.com/2863474 插件,可以将CSS格式化成一行,也可以将一行格式化成多行. 下载解压缩之后,将compact_expand_css_com ...
- HDU 1011 Starship Troopers 树形DP 有坑点
本来是一道很水的树形DP题 设dp[i][j]表示,带着j个人去攻打以节点i为根的子树的最大收益 结果wa了一整晚 原因: 坑点1: 即使这个节点里面没有守卫,你如果想获得这个节点的收益,你还是必须派 ...