Getting WA for larger test case

programming
Tags: #<Tag:0x00007f2425e8b7a0>

#1

#define ll long long
#define mod 1e9+7
vector Solution::solve(vector &A, vector &B)
{
ll n=100001;
ll arr[n];
arr[1]=1;arr[3]=3;arr[2]=2;
for(ll i=4;i<n;i++)
{
set s;
set::iterator it;
for(ll j=1;jj<=i;j++)
if(i%j==0) s.insert(j),s.insert(i/j);
ll sum=1;
for(it=s.begin();it!=s.end();it++)
{
sum=(sum
((it)%1000000007));
sum=sum%1000000007;
}
arr[i]=sum;
}
vector v;
ll sz=(A.size()
(A.size()+1))/2;
sort(A.begin(),A.end());
for(ll i=0;i<B.size();i++)
{
ll k=sz-B[i]+1;
ll g=(sqrt(1+8k) - 1)/2;
if((g
(g+1))/2!=k) g++;
v.push_back(arr[A[g-1]]);
}
return v;
}