BBP算法板子
来源:互联网 发布:java装饰模式和注解 编辑:程序博客网 时间:2024/06/05 05:32
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6217
百度BBP解释:https://wenku.baidu.com/view/716dbac708a1284ac85043bf.html
板子,不会,别问我
#include <cstdio>#include<iostream>using namespace std;typedef long long ll;ll remain( ll m, ll n, ll k, ll extra){ ll temp1=1,temp2=1; if(n==0)return extra%k; if(n==1)return (m*extra)%k; while(n>1) { temp1=m; temp1*=temp1; if(temp1>=k)temp1%=k; if(n%2==1)temp2=m*temp2; temp2%=k; m=temp1; n=n/2; } temp1=(temp1*temp2)%k; return (temp1*extra)%k;} ll remain_nex( ll m, ll n, ll k){ ll temp1=1,temp2=1; if(n==0)return 1; if(n==1)return m%k; while(n>1) { temp1=m; temp1*=temp1; if(temp1>=k)temp1%=k; if(n%2==1)temp2=m*temp2; temp2%=k; m=temp1; n=n/2; } return (temp1*temp2)%k;}char compute_n(int j){ ll m; long double sum=0,temp=1.0,temp1; int i; j--; temp1=1.0; for(i=0;i<=j;i++)sum=sum+remain(16,j-i,8*i+1,4)/(long double)(8.0*i+1); for(i=0;i<=j;i++)sum=sum-remain(16,j-i,8*i+4,2)/(long double)(8.0*i+4); for(i=0;i<=j;i++)sum=sum-remain_nex(16,j-i,8*i+5)/(long double)(8.0*i+5); for(i=0;i<=j;i++)sum=sum-remain_nex(16,j-i,8*i+6)/(long double)(8.0*i+6); temp=1.0; for(;temp>0.000001;i++) { temp=temp/16.0;sum=sum+(4.0/(8*i+1)-2.0/(8*i+4)-1.0/(8*i+5)-1.0/(8*i+6))*temp; } for(;sum<0;)sum=sum+16; m=sum; sum=sum-m; sum=sum*16; m=sum; return (char)(m<10 ? m+48: m+55);}int main(){ int T, ca, i, n; scanf("%d", &T); for (ca = 1;ca <= T;ca++) { scanf("%d", &n); printf("Case #%d: %d %c\n", ca, n, compute_n(n)); }}
阅读全文
0 0
- BBP算法板子
- KM算法板子
- KM算法板子2
- 【板子】Dinic算法
- Tarjan算法板子
- hdu 2255 KM算法板子
- 板子
- 板子
- HDU6217 BBP Formula
- BBP项目Sql语句拼接
- 用BBP公式计算π
- 二分图匹配——匈牙利算法の板子
- 线性规划——单纯形算法の板子
- 求解离散对数——BSGS算法の板子
- 二分图最大权匹配 KM算法 板子
- [bzoj2038][莫队算法][板子]小Z的袜子
- Struts与Spring整合:bbp project
- 24bbp的bmp转RGB565
- guava之ImmutableList三种初始化方式的使用实例
- ARP协议以及攻击欺骗和防御
- python面试题(3)
- String的split方法
- [IP池]阿里云Ubuntu配置各种乱七八糟工具
- BBP算法板子
- 2016 China-Final Ice Cream Tower(二分)
- sql
- 【AI_数学知识】概率论
- Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks论文笔记
- CodeForces
- iOS去除导航栏和tabbar的1px横线
- 不同品牌的光模块可以互连吗?
- C++11新特性