See the problem: DCP-316: Names
/* Bismillahir Rahmanir Rahim
Its just a string multiplication.
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a, i, j, n, t, z, sz, ar[1000001];
string s;
void multiply(int i){ // string multiplication
int carry=0, j;
for(j=10000; j>10000-z; j--){
int temp=ar[j]*i+carry;
ar[j]=temp%10;
carry=temp/10;
}
while(carry){
ar[j--]=carry%10;
carry=carry/10;
z++;
}
}
int main(){
cin>>t;
while(t--){
cin>>n>>s;
sz=s.size();
ar[10000]=1;
n=n-sz, z=1;
for(i=1; i<=n; i++){
multiply(26);
}
for(i=10001-z; i<=10000; i++) cout<<ar[i];
cout<<endl;
}
return 0;
}
|
No comments:
Post a Comment