Submission #480277

#TimeUsernameProblemLanguageResultExecution timeMemory
480277Jarif_RahmanVepar (COCI21_vepar)C++17
70 / 70
263 ms9600 KiB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int lim = 1e7+1;
vector<bool> prm(lim, 1);
vector<int> pp;
vector<ll> cnt;
void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, c--;
    for(int i = 0; i < pp.size(); i++){
        ll ss = pp[i];
        while(ss <= b){
            ll x = b/ss, y = a/ss;
            cnt[i] += x-y;
            ss*=pp[i];
        }
    }
    for(int i = 0; i < pp.size(); i++){
        ll ss = pp[i];
        while(ss <= d){
            ll x = d/ss, y = c/ss;
            cnt[i] -= x-y;
            ss*=pp[i];
        }
    }
    bool bl = 1;
    
    for(int i = 0; i < pp.size(); i++){
        if(cnt[i] > 0) bl = 0;
        cnt[i] = 0;
    }
    cout << (bl? "DA":"NE") << "\n";
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 2; i*i < lim; i++) if(prm[i]) for(int j = i*i; j < lim; j+=i) prm[j] = 0;
    for(int i = 2; i < lim; i++) if(prm[i]) pp.pb(i);
    cnt.assign(pp.size(), 0);
    int T; cin >> T; while(T--) solve();
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < pp.size(); i++){
      |                    ~~^~~~~~~~~~~
Main.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i = 0; i < pp.size(); i++){
      |                    ~~^~~~~~~~~~~
Main.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i = 0; i < pp.size(); i++){
      |                    ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...