Facebook
From trần bá nguyên, 1 Year ago, written in Plain Text.
This paste is a reply to coutnum from trần bá nguyên - go back
Embed
Viewing differences between coutnum and beaunum
#include
#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define pub push_back
#define pob pop_back
#define ii  pair
#define pll pair
#define F first
#define S second
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
typedef unsigned long long int ull;
typedef long long ll;
const long N=1e6 + 5;
const int mod = 1e9 +7;
using namespace std;
long long gcd(long long int a, long long int b) 

  if (b 
ll n,res=0;
bool kt[N+1];
void them(){
    FOR(i,0,N) {
        kt[i] = true;
    }
    kt[0] = false;
    kt[1] = false;
    for(int i = 2; i * i <= N; ++i) {
         if(kt[i] 
== 0) 
    return a; 
  return gcd(b, a % b); 

long long lcm(int a, int b) 

    return (a / gcd(a, b)) 
true) {
             for(int j = i 
b; 
i; j <= N; j += i)
                 kt[j] = false;
        }
    }
}
void solve()
{
 long long a,b,c,d;
 cin>>a>>b>>c>>d;
    long long p,x,y,z,t=0;
    p=b-a+1;
    x=b/c-(a-1)/c;
    y=b/d-(a-1)/d;
    z=b/lcm(c,d)-(a-1)/lcm(c,d);
    t=x+y-z;
    cout<
solve(){
    them();
    cin >> n;
    n=sqrt(sqrt(n));
    for(int i=1;i<=n;i++)
    {
        if (kt[i]) res++;
    }
    cout << res;
}
int main()
{
 freopen("countnum.
main(){
    fast;
     freopen("beaunum.
inp","r",stdin);
 freopen("countnum.     freopen("beaunum.out","w",stdout);
 solve();\n    solve();
    return 0;
}