Cod sursa(job #3329534)

Utilizator 20r50Gheorghies Robert 20r50 Data 13 decembrie 2025 20:17:39
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.07 kb
#include <bits/stdc++.h>
#define ll long long
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define pii pair<int,int>
#define mii map<ll,ll>
#define ld long double
#define fxtsetp fixed<<setprecision
using namespace std;
const ll NMAX=2e6+5;
const ll MOD=72;
bitset<NMAX> c;
ll s;
void ciur(ll n){
    c[0]=c[1]=1;
    for(ll i=2;i<=n;i++){
        if(c[i]==0){
            s++;
            for(ll j=2*i;j<=n;j+=i)
                c[j]=1;
        }
    }
}
void probleme(){
    ll n;
    cin>>n;
    ciur(n);
    cout<<s;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("thing2.in","r",stdin);
    freopen("thing2.out","w",stdout);
#else
    freopen("ciur.in","r",stdin);
    freopen("ciur.out","w",stdout);
#endif
    //ll t; cin>>t; while(t--)
    probleme();
    return 0;
}
/**
x = 9x+r1
x = 8y+r2

x=72x-72y+8r1-9r2
 =72(x-y)+8r1-9r2
 =8r1-9r2

 r1 : if N(n) = 1 => nnn %8
              = 2 => u(n)n %8 , k>=2

              = n%8 , n>99 si/sau k=1

 r2 : S(n) * k %9
**/