Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <bits/stdc++.h>
- //%lld
- typedef long long ll;
- using namespace std;
- bool comp(int a, int b){
- return a>b;
- }
- ll primo[1000000];
- ll vetor[1000000];
- ll aux[1000];
- int main(){
- for(ll i = 1;i<=1000000;i++){
- primo[i]=1;
- }
- for(ll i = 2;i<=1000000;i++){
- if(primo[i]){
- for(ll j = 2*i;j<=1000000;j+=i){
- primo[j] = 0;
- }
- }
- }
- int a, b, c, d, z = 0, maior = 0;
- bool p = false;
- cin>>a>>b;
- for(int i = a;i<=b;i++){
- if(primo[i]==1){
- aux[z] = i;
- z++;
- }
- }
- for(int i = 1;i<=z;i++){
- int t = aux[i]-aux[i-1];
- vetor[aux[i]-aux[i-1]]++;
- }
- int saida = 0, q = 0;
- for(int i = 0;i<=b;i++){
- if(vetor[i]>saida){
- saida = vetor[i];
- q = i;
- }
- }
- if(q==0)cout<<"-1"<<endl;
- else cout<<q<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment