here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Saturday 25 October 2014

Large subsequence Problem

problem statement is here



#include<stdio.h>
#include<string.h>
#define mod 1000000007
int main(){
int c=1,i,n,t,u,v,s;
char ar[10011];
scanf("%d",&t);
while(t--){
s=0;
int br[11]={0};
scanf("%s",ar);
n=strlen(ar);
for(i=0;i<n;i++){
v=u=ar[i]-48;
while(v--){
br[u]=(br[u]+br[v])%mod;
}
br[u]++;
}
for(i=0;i<=9;i++){
s=(s+br[i])%mod;
}
printf("Case %d: %d\n",c,s);
c++;
}
return 0;
}

No comments:

Post a Comment