fork download
  1. #include <bits/stdc++.h>
  2. //#define int long long
  3. #define double long double
  4. #define fi first
  5. #define se second
  6. #define endl "\n"
  7. #define ii pair<int,int>
  8. #define iii pair<ii,int>
  9. using namespace std;
  10. const int mod=998244353;
  11. const int N=1e6+5;
  12. bool nt(int n){
  13. for (int i=2; i<=sqrt(n); ++i){
  14. if (n%i==0) return false;
  15. }
  16. return true;
  17. }
  18. signed main(){
  19. cin.tie(0) -> sync_with_stdio(false);
  20. freopen("BAI1.INP","r",stdin);
  21. freopen("BAI1.OUT","w",stdout);
  22. string s; cin >> s;
  23. for (int i=0; i<s.size(); ++i){
  24. if (!isdigit(s[i])) s[i]=' ';
  25. }
  26. stringstream ss(s);
  27. int ans=0;
  28. while (ss >> s){
  29. if (s.size()>7) continue;
  30. else {
  31. int n=stoi(s);
  32. if (nt(n)) ans=max(ans,n);
  33. }
  34. }
  35. cout << ans;
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty