标签:des style blog color java os strong io
1 10 16807 282475249 1622650073 984943658 1144108930 470211272 101027544 1457850878 1458777923 2007237709 10 1 3 6 74243042 2 4 8 16531729 1 3 4 1474833169 2 1 8 1131570933 2 7 9 1505795335 2 3 7 101929267 1 4 10 1624379149 2 2 8 2110010672 2 6 7 156091745 1 2 5 937186357
16807 937186357 937186357 937186357 937186357 1 1 1624379149 1624379149 1624379149
#include<cstdio>
#include<stack>
using namespace std;
typedef __int64 LL;
const int N = 1e5 + 10;
struct opertion
{
int t, l, r;
LL x;
}o[N];
LL a[N];
LL gcd(LL x, LL y)
{
while(y) {
LL r = x % y;
x = y;
y = r;
}
return x;
}
int main()
{
int T, n, i, j, Q;
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
for(i = 1; i <= n; i++)
scanf("%I64d",&a[i]);
scanf("%d",&Q);
for(i = 0; i < Q; i++)
scanf("%d%d%d%I64d",&o[i].t, &o[i].l, &o[i].r, &o[i].x);
for(i = 1; i <= n; i++) {
stack<LL> s;
int flag = 0;
for(j = Q - 1; j >= 0; j--) {
if(i >= o[j].l && i <= o[j].r) {
s.push(o[j].x);
if(o[j].t == 1) {
flag = 1;
break;
}
}
}
if(!flag) //没有遇到1操作
s.push(a[i]);
while(s.size() > 1) {
LL ans = s.top(); s.pop();
LL tmp = s.top(); s.pop();
if(ans > tmp)
ans = gcd(ans, tmp);
s.push(ans);
}
printf("%I64d ", s.top());
}
printf("\n");
}
return 0;
}hdu 4902 Nice boat(2014多校训练第4场 1006),布布扣,bubuko.com
hdu 4902 Nice boat(2014多校训练第4场 1006)
标签:des style blog color java os strong io
原文地址:http://blog.csdn.net/lyhvoyage/article/details/38330819