# Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

# Description

Long long ago, there was a super computer that could deal with VeryLongIntegers(no VeryLongInteger will be negative). Do you know how this computer stores the VeryLongIntegers? This computer has a set of n positive integers: b1,b2,...,bn, which is called a basis for the computer.

The basis satisfies two properties:
1) 1 < bi <= 1000 (1 <= i <= n),
2) gcd(bi,bj) = 1 (1 <= i,j <= n, i ≠ j).

Let M = b1*b2*...*bn

Given an integer x, which is nonegative and less than M, the ordered n-tuples (x mod b1, x mod b2, ..., x mod bn), which is called the representation of x, will be put into the computer.

# Input

The input consists of T test cases. The number of test cases (T) is given in the first line of the input.
Each test case contains three lines.
The first line contains an integer n(<=100).
The second line contains n integers: b1,b2,...,bn, which is the basis of the computer.
The third line contains a single VeryLongInteger x.

Each VeryLongInteger will be 400 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).

# Output

For each test case, print exactly one line -- the representation of x.
The output format is:(r1,r2,...,rn)

# Sample Input

2

3
2 3 5
10

4
2 3 5 7
13

# Sample Output

(0,1,0)
(1,1,3,6)

#include <stdio.h>
#include <memory.h>

int main()
{
int test;
scanf("%d", &test);
while (test--) {
int num;
scanf("%d", &num);
int basis[num];
for (int c = 0; c < num; ++c)
scanf("%d", &basis[c]);
char VeryLongInteger[400];
scanf("%s", VeryLongInteger);

int ans[num];
memset(ans, 0, sizeof(ans));

int temp;
for (int c = 0; c < strlen(VeryLongInteger); ++c) {
temp = VeryLongInteger[c] - '0';
for (int d = 0; d < num; ++d) {
ans[d] = (ans[d] * 10 + temp) % basis[d];
}
}

for (int c = 0; c < num; ++c)
if (c == 0)
printf("(%d", ans[c]);
else if (c == num - 1)
printf(",%d)\n", ans[c]);
else
printf(",%d", ans[c]);
}
}

#### Sicily 1020. Big Integer

2013-09-08 17:46:15

#### [sicily]1020. Big Integer

2015-09-23 16:41:27

#### [sicily] 1020. Big Integer

2016-05-12 20:08:15

#### [sicily online]1020. Big Integer

2012-11-26 16:05:25

#### Sicily 1020. Big Integer | 大整数取模运算

2017-06-29 13:41:11

#### 1020. Big Integer（高精度运算）

2015-11-21 00:22:26

#### 1020. Big Integer

2014-09-23 17:58:56

#### sicily 1020 Big Integer

2011-05-31 20:56:00

#### Sicily 1020 Big Integer

2013-10-09 14:40:38

#### sicily 1020 Big Integer

2014-12-15 17:08:31

## 不良信息举报

sicily 1020. Big Integer