栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

ICPC North Central NA Contest 2018 C . Rational Ratio(结论 模拟 gcd)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ICPC North Central NA Contest 2018 C . Rational Ratio(结论 模拟 gcd)

linkkkk

题意:

给出一个无限小数和循环节,将其化成最简分式。

思路:

先有个结论是

0.456=456/999

按照这种模拟就好了。
如果说,循环节不是全部的小数位的话,先将多余的数变到小数点前,处理后再变回去。
比如 0.14757575 0.14757575 0.14757575,可以先变成 14.757575 14.757575 14.757575,最后再除以 100 100 100

代码:
#include
using namespace std;
typedef long long ll;typedef unsigned long long ull;
typedef pairPLL;typedef pairPII;typedef pairPDD;
#define I_int ll
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
#define read read()
#define rep(i, a, b) for(int i=(a);i<=(b);++i)
#define dep(i, a, b) for(int i=(a);i>=(b);--i)
ll ksm(ll a,ll b,ll p){ll res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
const int maxn=4e5+7,maxm=1e6+7,mod=1e9+7;

int main(){
	string s;cin>>s;
	int k=read;
	ll sum9=0;
    for(int i=1;i<=k;i++) sum9=sum9*10+9;
    ll pos=-1,pre=0,las=0;
    for(int i=0;i
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/329999.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号