Time Limit: 1000ms Memory Limit: 100000k
Description
Kim刚刚学会C语言中的取模运算(mod)。他想要研究一下一个数字A模上一系列数后的结果是多少。帮他写个程序验证一下。
Input
第一行一个整数T代表数据组数。
接下来T组数据,第一行一个整数n,接下来n个数字ai
接下来一行一个整数m,接下来m个数字bi
Output
对于每个bi,输出bi%a1%a2%...%an
Sample
Input
Output
1
4
10 9 5 7
5
14 8 27 11 25
4
3
2
1
0
Hint
在C语言中,A mod B 是 a%b
样例解释:
14%10%9%5%7=4
8%10%9%5%7=3
...
数据范围:
1<=n<=100000
1<=m<=100000
1<=ai<=1000000000
0<=bi<=1000000000
大数据的处理方法之一 二分法
/*
_...---.._
,' ~~"--..
/ ~"-._
/ ~-.
/ . `-.
-. `-.
~-. `-.
,-~~ ~.
/ `.
. `.
| .
|
. `.
` `.
` .
` `.
. -.
` -.
. ` - .
` ~-
` . ~.
. -_
` -
. | ~.
` |
. |
` | `.
` `
. . `. `.
` : `.
` `.
. `. `~~-.
: `
. . : `.
` : | | .
. | |
: ` | `
. . | |_ .
` `. ` ` | ~.;
`. . . .
. `. ` ` `
`. `._. `.
` < `. | .
` ` : ` | |
` ` | |
`. | : .' |
"Are you crying? " ` | `_-' |
"It's only the rain." : | | | : ;
"The rain already stopped."` ; |~-.| : '
"Devils never cry." : | ` ,
` ` : '
: ` `_/
` . "For we have none. Our enemy shall fall."
` ` "As we apprise. To claim our fate."
| : "Now and forever. "
.' : "We'll be together."
: : "In love and in hate"
| .'
| : "They will see. We'll fight until eternity. "
| ' "Come with me.We'll stand and fight together."
| / "Through our strength We'll make a better day. "
`_.' "Tomorrow we shall never surrender."
sao xin*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define eps 1e-6
#define INF 0x3f3f3f3
#define pi acos(-1)
using namespace std;
//const LL INF = 1e15;
const int maxn=1e3+5;
const int maxx=1e5+5;
//const double q = (1 + sqrt(5.0)) / 2.0; // 黄金分割数
/*
std::hex <<16进制 cin>>std::hex>>a>>std::hex>>b
cout.setf(ios::uppercase);cout<
b=b>>1; 除以2 二进制运算
//f[i]=(i-1)*(f[i-1]+f[i-2]); 错排
/ for (int i=1; i<=N; i++)
for (int j=M; j>=1; j--)
{
if (weight[i]<=j)
{
f[j]=max(f[j],f[j-weight[i]]+value[i]);
}
}
priority_queue,greater >que3;//注意“>>”会被认为错误,
priority_queue,less >que4;////最大值优先
//str
//tmp
//vis
//val
//cnt 2486
*/
LL a[maxx];
void solve()
{
int n;
LL k;
cin>>n;
while(n--)
{
int num1,num2;
cin>>num1;
for(int i=1;i<=num1;i++)
cin>>a[i];
LL tot=1;
for(int i=2;i<=num1;i++)
{
if(a[i]
{
tot++;
}
}
n=tot;
cin>>num2;
for(int i=1;i<=num2;i++)
{
cin>>k;
while(1)
{
LL x=0,y=n+1;
while(y-x>1)
{
LL mid=x+(y-x)/2;
if(k>=a[mid])
{
y=mid;
}
else x=mid;
}
if(y==n+1)
break;
k%=a[y];
}
cout<
}
}
}
int main()
{
solve();
}