Problem A
Accepts: 961
Submissions: 7895
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
坑啊 一开始可能数据有错,晚上可能数据又改了
前缀数组+逆元
线段树会超时
#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include<cstring>
#define LL long long
#define maxn 150000
#define MOD 9973
using namespace std;
char str[maxn];
int ans[maxn];
int qpow( int a,int n)
{
int temp=a;
int ans=1;
while(n>0)
{
if(n&1)
ans=ans*temp%MOD;
temp=(temp*temp)%MOD;
n>>=1;
}
return ans;
}
int main()
{
int n;
while(~scanf("%d",&n))
{
getchar();
gets(str);
ans[0]=1;
int len=strlen(str);
for(int i=0;i<len;++i)
{
ans[i+1]=(ans[i]*(str[i]-28))%MOD;
}
while(n--)
{
int a,b;
scanf("%d%d",&a,&b);
int fin=(ans[b]*qpow(ans[a-1],MOD-2) )%MOD;
printf("%d\n",fin);
}
}
}