比赛 |
防止浮躁的小练习v0.9 |
评测结果 |
AAAAAAATTTTTTTTTTTTT |
题目名称 |
__卡片游戏 |
最终得分 |
35 |
用户昵称 |
Bravo ChaoS |
运行时间 |
27.913 s |
代码语言 |
C++ |
内存使用 |
2.11 MiB |
提交时间 |
2016-11-07 14:28:55 |
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define FI(x) freopen(x".in","r",stdin);
#define FO(x) freopen(x".out","w",stdout);
using namespace std;
const int maxn=500010;
int n,l,r,a[maxn],L,R,fst,ans=0,all,d;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
void RD(int& x)
{
char c=' '; x=0;
while(c<'0' || c>'9') c=getchar();
while(c>='0' && c<='9') {x=x*10+c-'0';c=getchar();}
}
class input{
public:
input & operator >>(int & i){
RD(i);
return *this;
}
}scan;
int main()
{
FI("xgame");
FO("xgame");
scan>>n>>L>>R;
all=(n+1)*n>>1;l=L<<1,r=R<<1;
if(all==0)
{
printf("0\n");
return 0;
}
for(int i=1;i<=n;++i) {scan>>a[i];
if(a[i]>=L && a[i]<=R) ++ans;}
fst=a[1];
for(int k=2;k<=n;l+=L,r+=R,++k)
{
fst+=a[k];
for(int i=k,t=fst;i<=n;++i,t+=a[i]-a[i-k])
if(t>=l && t<=r) ++ans;
}
d=gcd(ans,all);
ans/=d,all/=d;
if(all==1) printf("1\n");
else printf("%d/%d\n",ans,all);
return 0;
}
/*
4 2 3
3 1 2 4
*/