Compile Error
foo.cc: In function 'int main()': foo.cc:19:31: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)' 19 | if(x>1)value.push_back({x,1}); | ~~~~~~~~~~~~~~~^~~~~~~ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/functional:64, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53, from foo.cc:1: /usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1281 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1281:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>::value_type&' {aka 'const int&'} 1281 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]' 1298 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1298:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'} 1298 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~
Code
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int n,x;
cin>>n>>x;
vector<int>value;
vector<int>arr(n+1,0);
for(int i=2;i<=sqrt(x)+1;i++){
// cout<<"haha "<<x<<" "<<i<<endl;
while(x%i==0){
value.push_back(i);
x/=i;
}
}
if(x>1)value.push_back({x,1});
for(int i=0;i<n;i++){
cin>>arr[i];
}
sort(value.begin(),value.end());
int age=0;
int pt=0;
vector<pair<int,int>>vv;
for(int i=0;i<value.size();i++){
if(pt==0)pt=value[i];
if(pt==value[i])++age;
else{
vv.push_back({pt,age});
pt=value[i];
age=0;
}
}
vv.push_back({pt,age});
// for(int i=0;i<vv.size();i++)cout<<vv[i].first<<" "<<vv[i].second<<endl;
vector<vector<int>>sum(vv.size()+1,vector<int>(n+1,0));
for(int i=0;i<n;i++){
int kk=arr[i];
for(int j=0;j<vv.size();j++){
while(kk%vv[j].first==0){
sum[j][i]++;
kk/=vv[j].first;
}
}
}
for(int i=1;i<n;i++){
for(int j=0;j<vv.size();j++){
sum[j][i]+=sum[j][i-1];
// cout<<sum[j][i]<<" ";
}
// cout<<endl;
}
vector<int>akn(n+1,INT_MAX);
for(int i=0;i<n;i++){
int low=0,high=n-1;
vector<int>biyok(vv.size(),0);
if(i!=0){
for(int j=0;j<vv.size();j++)biyok[j]=sum[j][i-1];
}
int ans=INT_MAX;
while(high>=low){
int mid=(high+low)/2;
int flag=0;
for(int j=0;j<vv.size();j++){
if(sum[j][mid]-biyok[j]<vv[j].second)flag=1;
}
if(!flag){
ans=mid;
high=mid-1;
}else low=mid+1;
}
akn[i]=ans;
}
for(int i=n-2;i>=0;i--){
akn[i]=min(akn[i],akn[i+1]);
}
int q;
cin>>q;
while(q--){
int a,b;
cin>>a>>b;
if(akn[a-1]<=b-1)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1128 Roy and Product
- Contest
- Brain Booster #7
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 15:39:26
- Judged At
- 2024-11-05 15:39:26
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes