hdu-1261
String
#include <stdio.h>
#include <string.h>
int len,a[1000];
void Jiecheng (int n)
{
int I,j,temp,carry;
A[0]=1;
Len=1;
for (i=2;i<=n;i++)//Development function
{
carry=0;
for (j=0;j<len;j++)
{
Temp=a[j]*i+carry;
a[j]=temp%10000;
carry=temp/10000; Storage functions, rounding to high places
}
if (carry)
A[len++]=carry;
}
}
int main ()
{
int i,j,k,n,temp;
int Sum,num[26],carry;
while (~SCANF ("%d", &n), n!=0)
{
sum=0;
for (i=0;i<n;i++)
{
scanf ("%d", &num[i]);
Sum+=num[i];
}
Jiecheng (sum);
for (i=0;i<n;i++)
{
for (j=2;j<=num[i];j++)
{
carry=0;
for (k=len-1;k>=0;k--)
{
temp=a[k]+carry*10000; Remove from high
a[k]=temp/j;
Carry=temp%j;
}
if (a[len-1]==0) len--;
}
}
printf ("%d", a[len-1]);
for (i=len-2;i>=0;i--)
printf ("%04d", A[i]);
printf ("\ n");
}
return 0;
}
Lovekey
Time limit:3000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 5974 Accepted Submission (s): 1969
Problem Description XYZ-26 binary number is a number that is a capital letter per digit. A, B, C 、...、 X, Y, Z, respectively, represent a number 0 ~ 25, and an n-bit 26 binary number is converted into a 10-binary rule as follows
A0a1a2a3 ... The number of each digit represented by the An-1 is a0a1a2a3...an-1, then the 10 binary value of the XYZ-26 number is
m = a0 * 26^ (N-1) + A1 * 26^ (N-2) + ... + an-3* 26^2 + an-2*26 + an-1
One day Vivi suddenly played a romantic, to hide in the school of a classroom, let maple ice leaves to find, of course, she also know maple ice leaves is not road fetish, so found XYZ small shrimp and water prodigal help, they will in the door of the classroom of the XYZ-26, respectively write a number of a and B, respectively, And a password is set on the door lock. Obviously, only the password can be found to open the lock, smoothly into the classroom. This set of passwords is called Lovekey by the members of XYZ. Fortunately, Maple ice leaves know that Lovekey is a 10 binary value with B's 10 binary value and the XYZ-26 binary form. Of course, the shrimp and water prodigal son do not want to difficult maple ice leaves, so a and B are not more than 200 digits.
For example, the first set of test data
A = 0 * 26^5+0* 26^4+ 0* 26^3+ 0 *26^2 + 3*26 + 7 = 85
b = 1*26^2 + 2*26 + 4 = 732
Then A + b = 817 = BFL
The Input topic has multiple sets of test data.
Each set of test data contains a XYZ-26 number of two values, each of which contains only uppercase letters and no more than 200 bits per digit.
Output Lovekey of XYZ, one row per set of outputs.
Sample Input
Aaaadh BCE DRW UHD D AAAAA
Sample Output
BFL XYZ D
This problem is the conversion between the system, in fact, or the principle of the addition of large numbers
#include <stdio.h>
#include <string.h>
int main ()
{
int i,j,k,t;
Char a[300];
Char b[300];
int c[500];
int num1,num2;
GetChar ();
while (~SCANF ("%s%s", A, b))
{
k=0;
Memset (C,0,sizeof (c));
Num1=strlen (a);
Num2=strlen (b);
For (i=num1-1,j=num2-1;i>=0&&j>=0;i--, j--)
{
c[k]+=a[i]+b[j]-' A '-' a ';
if (c[k]>25)
{
c[k]-=26;
c[k+1]++;
}
k++;
}
while (i>=0)
{
c[k]+=a[i--]-' a ';
if (c[k]>25)
{
c[k]-=26;
c[k+1]++;
}
k++;
}
while (j>=0)
{
c[k]+=b[j--]-' A ';
if (c[k]>25)
{
c[k]-=26;
c[k+1]++;
}
k++;
}
while (c[k]==0&&k>=1) k--;
for (; k>=0;k--)
printf ("%c", c[k]+65);
printf ("\ n");
}
return 0;
}