大数取模。将大数字符串从头到尾扫一遍,模拟平时除法运算取模的方法。
// Problem#: 1020
// Submission#: 2198449
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <string>
#include <stack>
using namespace std;
int main(){
int t;
cin >>t;
while(t--){
int n;
vector<int> v(105);
cin >> n;
for(int i = 0; i < n; i++)
cin >> v[i];
string s;
cin >> s;
cout << "(";
for(int j = 0 ; j < n; j++){
int res = 0;
for(int i = 0; i < s.size(); i++){
res = (res *10 + (s[i]-'0')) % v[j];
}
if(j == n-1)
cout << res <<")" << endl;
else
cout << res << ",";
}
}
}