update
This commit is contained in:
parent
4d387280dc
commit
7ceea85559
61
src/11/27/P7960.cpp
Normal file
61
src/11/27/P7960.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <bitset>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
using ll = int64_t;
|
||||||
|
|
||||||
|
ll const maxx{ll(1e6+5)};
|
||||||
|
ll t,x,minPrim[maxx],isSeven[maxx];
|
||||||
|
bitset<maxx>isPrim;
|
||||||
|
|
||||||
|
void initPrim(){
|
||||||
|
isPrim.set();
|
||||||
|
for(ll i{2};i<=maxx;i++){
|
||||||
|
if(isPrim[i]){
|
||||||
|
for(ll j{i+i};j<=maxx;j+=i){
|
||||||
|
isPrim[j]=false;
|
||||||
|
if(!minPrim[j]){
|
||||||
|
minPrim[j]=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool check(ll const& num){
|
||||||
|
if(isSeven[num]!=0)return isSeven[num]==-1?false:true;
|
||||||
|
ll tmp{num};
|
||||||
|
while(tmp!=0){
|
||||||
|
if(tmp%10==7){
|
||||||
|
isSeven[num]=true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isSeven[num]=-1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
||||||
|
|
||||||
|
initPrim();
|
||||||
|
|
||||||
|
for(ll i{1};i<=10;i++){
|
||||||
|
cout<<isPrim[i]<<' ';
|
||||||
|
}
|
||||||
|
cout<<'\n';
|
||||||
|
for(ll i{1};i<=10;i++){
|
||||||
|
cout<<minPrim[i]<<' ';
|
||||||
|
}
|
||||||
|
cout<<'\n';
|
||||||
|
|
||||||
|
cin>>t;
|
||||||
|
while(t--){
|
||||||
|
cin>>x;
|
||||||
|
while(x!=0){
|
||||||
|
if(check(minPrim[x])){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,71 +1,22 @@
|
|||||||
#include <array>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <random>
|
#include <memory>
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using ll = int64_t;
|
|
||||||
|
|
||||||
template<class T,class P>
|
|
||||||
ostream&operator<<(ostream&os,pair<T,P>const&p){
|
|
||||||
os<<"( "<<p.first<<", "<<p.second<<" )";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
variant<ll,string> test(){
|
|
||||||
random_device v;
|
|
||||||
mt19937 mt(v());
|
|
||||||
uniform_int_distribution<short> un(0,50);
|
|
||||||
ll number{un(mt)};
|
|
||||||
if(!number){
|
|
||||||
return "Zengtudor";
|
|
||||||
}
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
|
|
||||||
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
|
||||||
|
|
||||||
template<class T,class ...Args>
|
|
||||||
struct Array{
|
|
||||||
static constexpr ll size(){return sizeof...(Args)+1;}
|
|
||||||
decay_t<T> arr[size()];
|
|
||||||
Array(T const&t, Args const&...args){
|
|
||||||
arr[0]=t;
|
|
||||||
ll idx{1};
|
|
||||||
((arr[idx++]=args),...);
|
|
||||||
}
|
|
||||||
friend ostream&operator<<(ostream&os,Array const&arr){
|
|
||||||
os<<"[ ";
|
|
||||||
for(ll i{0};i<size();i++){
|
|
||||||
os<<arr.arr[i]<<" ,";
|
|
||||||
}
|
|
||||||
cout<<" ]";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// template<class T,class ...Args>
|
|
||||||
// Array(T,Args...)->Array<T,Args...>;
|
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
array<int,2> a{};
|
using namespace std;
|
||||||
for(auto const& i:a)cout<<i<<" ";
|
struct X{
|
||||||
cout<<'\n';
|
X(int const& x){cout<<"X is constructing: "<<x<<'\n';}
|
||||||
Array arr {1,2,3};
|
~X(){cout<<"X is dead\n";}
|
||||||
cout<<arr<<'\n';
|
};
|
||||||
// cout<<sizeof(test())<<'\n';
|
struct T{
|
||||||
// ll n{100};
|
T():t{1}{};
|
||||||
// // cin>>n;
|
int t;
|
||||||
// while(n--){
|
};
|
||||||
// cout<<visit(overloaded{
|
|
||||||
// [](string const&str){cout<<"is str\n";throw runtime_error("throwing error");return 1;},
|
auto b = make_unique<X>(1);
|
||||||
// [](ll const& n){cout<<"is number\n";return 2;}
|
int t{5};
|
||||||
// },test())<<"\n";
|
while(t--){
|
||||||
// }
|
T t;
|
||||||
|
cout<<t.t<<'\n';
|
||||||
|
}
|
||||||
|
cout<<"retrun 0;\n";
|
||||||
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user