Zhx ' s submissions
Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 1459 Accepted Submission (s): 232
Problem description
As one of the strongest brushes in history, Zhx handed in a lot of code to the big OJ, and most of them were AC. One day, Zhx wanted to count him in
n
How many copies of the code have been made on a OJ. He has now counted out the first
i
On a OJ, he handed in
< Span style= "LEFT:0EM; Top:-2.48em; Position:absolute ">a i
Copy code. And it's your job to add them up. Of course zhx is a person who does not take the usual road, so his numbers are used
B
In the binary representation. And he's asking you to tell him.
B
The number of the binary. But Zhx has a habit of bad taste, and he never carries it when he sums it up. Like he's a decimal.
5 + 6
The answer is
1
。 And he also asks you to do the addition in his own way.
Enter a description
Multiple sets of data (no more than
+
Group). Read the end of the file. For each set of data, the first row is a positive integer separated by two spaces
n
And
B
(
1≤n≤
,
2≤B≤
) Next
n
Line, one per line
B
Binary number
< Span style= "LEFT:0EM; Top:-2.48em; Position:absolute ">a i
。 The digital is 0 to 9 and lowercase a to Z. The input may contain a leading 0, and the number is no more than 200 digits long.
Output description
For each set of query outputs, a line of a
B
-number represents the answer. Cannot contain leading 0.
Input sample
2 3221 42333 16ABBCCD
Output sample
123314
Pure hand Speed Problem ~
This problem, because did not consider the answer of the leading 0,wa ...
#include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include < functional> #include <iostream> #include <cmath> #include <cctype> #include <ctime>using namespace std; #define for (I,n) for (int. i=1;i<=n;i++) #define FORK (I,k,n) for (int. i=k;i<=n;i++) #define REP (I,n) for (int i=0;i<n;i++) #define ForD (I,n) for (int. i=n;i;i--) #define REPD (I,n) for (int. i=n;i>=0;i--) #define FORP (x) for ( int p=pre[x];p; p=next[p]) #define FORPITER (x) for (int &p=iter[x];p; p=next[p]) #define LSON (x<<1) #define Rson ((x<<1) +1) #define MEM (a) memset (A,0,sizeof (a)), #define MEMI (a) memset (A,127,sizeof (a)), #define MEMI (a) memset ( A,128,sizeof (a)); #define INF (2139062143) #define MAXN (100000+10) #define MAXB (36+10) typedef long LONG Ll;int N,F,A[MAXN ],b[maxn];char s[maxn];void Add () {int len=b[0]; for (I,a[0]) {b[i]= (B[i]+a[i])%f;if (B[i]>0&&i>len) len=i;} B[0]=len;return;} int main () {//freopen ("Zhx ' s Submissions.in", "R", stdin); whiLe (scanf ("%d%d", &n,&f) ==2) {mem (a) mem (b) b[0]=1; for (i,n) {scanf ("%s", s), int m=strlen (s); int P=0;bool flag=0; Rep (i,m) {if (!flag&&s[i]== ' 0 ') continue;else flag=1;a[++p]= ' 0 ' <=s[i]&&s[i]<= ' 9 '? s[i]-' 0 ': s[ i]-' a ' +10;} A[0]=p; for (I,P/2) swap (a[i],a[p-i+1]); add ();} while (b[0]>1&&b[b[0]]==0)--b[0]; ForD (I,b[0]) printf ("%c", b[i]<=9?b[i]+ ' 0 ': b[i]-10+ ' a ');p rintf ("\ n");} return 0;}
Bestcoder Round #33 (Zhx's submissions-hand problem, pay attention to the situation of 00 and 0)