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 ...
随机推荐
- OpenSSL库验证PKCS7签名
使用Crypto库签名和验证签名请参考Crypto库实现PKCS7签名与签名验证,可以使用OpenSSL库验证Crypto签名,OpenSSL验证签名可使用简单的代码描述如下: //signature ...
- 【解决方案】: hyper-v 导入虚拟机报这个错误 32784
从win server 2012创建的虚拟机 导出后, 想导入到本机win8系统上,结果报错 32784, google了一堆,都说不支持... 实际上 1.在win8系统上 新建一个不带硬盘的虚拟机 ...
- 【转】关于 hashCode() 你需要了解的 3 件事
在 Java 中,每一个对象都有一个容易理解但是仍然有时候被遗忘或者被误用的 hashCode 方法.这里有3件事情要时刻牢记以避免常见的陷阱. 一个对象的哈希码允许算法和数据结构将对象放入隔间,就象 ...
- 设计模式初学者笔记:Factory Method模式
如果要选择一种最多人熟悉的Factory Method模式的具体应用,那么就应该是MFC的App/Doc架构了.Factory Method主要在类框架中使用,以解决以下问题:框架必须实例化类,但框架 ...
- Saltstack系列1:安装配置
安装 安装EPEL作为安装Ansible的yum源(CentOS6.4) rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel-release ...
- Linux下的ntpd和ntpdate
两者有个比较实质性的差异是,ntpd在实际同步时间时是一点点的校准过来时间的,最终把时间慢慢的校正对.而ntpdate不会考虑其他程序是否会阵痛,直接调整时间.一个是校准,一个是调整.另外ntpd 在 ...
- SVN在团队项目中的使用技巧:[2]Tag操作
SVN是Subversion的简称,是一个开放源代码的版本控制系统 本节讲述SVN使用中的TAG操作 文中若有错误或不足之处,欢迎留言指正 工具/原料 电脑 SVN 方法/步骤 1.认识SVN中T ...
- Unix commands in Mac OS X
参考:http://www.renfei.org/blog/mac-os-x-terminal-101.html One command line includes 4 parts: Command ...
- Navicat(连接)-1
连接 要在 Navicat 开始使用你的服务器,你要首先用连接窗口创建一个或多个连接.如果你是一个服务器新手和不肯定如何工作,你可能想看看: MySQL 用户手册 Oracle 数据库文件 Postg ...
- duplicate symbols
duplicate symbol _mCollecatView in: /Users/Rubert/Library/Developer/Xcode/DerivedData/ChengDuHidengD ...