比赛 |
noip |
评测结果 |
WAAWWWTTTTTTTTTTTTTT |
题目名称 |
__卡片游戏 |
最终得分 |
10 |
用户昵称 |
Lethur |
运行时间 |
28.769 s |
代码语言 |
C++ |
内存使用 |
1.99 MiB |
提交时间 |
2016-11-04 21:02:00 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#define MAXN 500001
using namespace std;
int n,l,r;
int A[MAXN]={0};
int son=0;
int mother=0;
int gcd(int a,int b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
freopen("xgame.in","r",stdin);
freopen("xgame.out","w",stdout);
cin>>n>>l>>r;
for(int i=1;i<=n;i++)
{
cin>>A[i];
}
int cnt=n;
for(int i=1;i<=n;i++)
{
int tmp=0;
int sum=0;
for(int j=0;j<=n-i;j++)
{
mother++;
sum+=A[i+j];
tmp++;
int ans=sum/tmp;
if(ans>=l&&ans<=r)
{
son++;
}
}
}
if(son==0||mother==0)
{
cout<<"0"<<endl;
return 0;
}
if(son==mother)
{
cout<<"1"<<endl;
return 0;
}
int num=gcd(mother,son);
mother/=num;
son/=num;
cout<<son<<"/"<<mother<<endl;
return 0;
}