蓝桥杯——分数

#include<iostream>
using namespace std;
typedef long long LL;
LL qmi(int a,int k){
    int res=1;
    while(k){
        if(k&1)res=(LL)res*a;
        k>>=1;
        a=(LL)a*a;
    }
    return res;
}
LL gcd(LL a,LL b){
    return b?gcd(b,a%b):a;
}
int main(){
    long long res=0;
    for(int i=0;i<=19;i++){
        res+=qmi(2,i);
    }
    LL t=gcd(res,qmi(2,19));
    cout<<(double)res/t<<"/"<<(double)qmi(2,19)/t<<endl;
    return 0;
}
posted @ 2020-10-11 20:24  进化の程序猿  阅读(85)  评论(0编辑  收藏  举报