//PiOtR - Piotr Obst 1 LO Chełm #include <iostream> typedef long long LL; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); short k; std::cin>>k; short tab[k]; long long N,M; std::cin>>N; for(short i=0;i<k;i++) std::cin>>tab[i]; M=N; while(M!=1){ M=N; for(short i=0;i<k;i++) while(!(M%tab[i])) M/=tab[i]; if(M!=1) N--; } std::cout<<N; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | //PiOtR - Piotr Obst 1 LO Chełm #include <iostream> typedef long long LL; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); short k; std::cin>>k; short tab[k]; long long N,M; std::cin>>N; for(short i=0;i<k;i++) std::cin>>tab[i]; M=N; while(M!=1){ M=N; for(short i=0;i<k;i++) while(!(M%tab[i])) M/=tab[i]; if(M!=1) N--; } std::cout<<N; return 0; } |