SCU 4519 来个签到吧 (exgcd推广+概率dp)
来源:互联网 发布:mac mini 更新时间 编辑:程序博客网 时间:2024/06/11 10:22
题目传送门:http://acm.scu.edu.cn/soj/problem.action?id=4519
这题开头给你一些球,然后把任意球的编号之差
前面加球,任意两个球
#include <map>#include <set>#include <stack>#include <queue>#include <cmath>#include <string>#include <vector>#include <cstdio>#include <cctype>#include <cstring>#include <sstream>#include <cstdlib>#include <iostream>#include <algorithm>#pragma comment(linker,"/STACK:102400000,102400000")using namespace std;#define MAX 100005#define MAXN 1000005#define maxnode 10#define sigma_size 2#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define LL long long#define ull unsigned long long#define mem(x,v) memset(x,v,sizeof(x))#define lowbit(x) (x&-x)#define pii pair<int,int>#define bits(a) __builtin_popcount(a)#define mk make_pair#define limit 10000//const int prime = 999983;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f;const double pi = acos(-1.0);const double inf = 1e18;const double eps = 1e-9;const LL mod = 1e9+7;const ull mxx = 1333331;/*****************************************************/inline void RI(int &x) { char c; while((c=getchar())<'0' || c>'9'); x=c-'0'; while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';}/*****************************************************/int gcd(int a,int b){ if(!b) return a; return gcd(b,a%b);}double dp[MAX];int main(){ //freopen("in.txt","r",stdin); int t; cin>>t; while(t--){ int n; cin>>n; int tmp,maxn=0; int flag=0; for(int i=0;i<n;i++){ int b; scanf("%d",&b); if(i==0) tmp=b; else tmp=gcd(tmp,b); maxn=max(maxn,b); if(b==0) flag=1; } int num=maxn/tmp+flag; int add=num-n; dp[num]=0; //cout<<num<<endl; for(int i=num-1;i>=0;i--){ dp[i]=dp[i+1]+num*1.0/(num-i); } int ans=dp[0]+add; cout<<ans<<endl; } return 0;}
0 0
- SCU 4519 来个签到吧 (exgcd推广+概率dp)
- [bzoj4720][Noip2016]换教室 签到概率DP
- SCU 4426 Counting_3 (dp)
- SCU 4511 任务(dp)
- SCU 1114-数字三角(dp)
- [SCU 4501] DNA序列 (状压DP)
- [SCU 4511] 任务 (状态优化DP)
- [SCU 4514] Simple dp (XJBLG法)
- SCU 4510 TaoSama与煎饼(dp)
- SCU 4512 Goozy的积木(dp)
- SCU 4515 又见背包(dp)
- BZOJ1004:[HNOI2008]Cards (Burnside引理+DP+Exgcd)
- URAL1776-------用DP来求概率
- 多校连萌 (4)GJJ来签到
- GJJ来签到 (河南多校联萌 四 )
- 河南多校赛(4)GJJ来签到
- 【zzuli 2178】(GJJ来签到)
- (多校联萌)zzu-2178: GJJ来签到
- stdafx.h(38) : fatal error C1083: 无法打开包括文件:“afxcontrolbars.h”解决办法
- 背包问题的自己理解
- zigzag相关题目
- GCC安装和使用的几个notes
- 利用Mongodb的复制集搭建高可用分片,Replica Sets + Sharding的搭建过程
- SCU 4519 来个签到吧 (exgcd推广+概率dp)
- maven+jetty容器搭建
- 什么?程序员还要了解经济学?!
- C++面向对象实验(六)(完结)
- 解析 Qt 网络之FTP 网络学习基础
- 环形队列的C++实现
- Python学习(一)——快速入门
- OC 中nil,Nil,NULL,NSNull的含义
- 论文阅读:Multi-view Convolutional Neural Networks for 3D Shape Recognition