SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5.  
  6. int main(){
  7.   int n, m;scanf("%d %d", &n, &m);
  8.   vector<ll> eventos(n), periodos(m);
  9.   ll gcd1=0;
  10.   for(int i=0;i<n;i++){
  11.     scanf("%lld", &eventos[i]);
  12.     gcd1=__gcd(gcd1, eventos[i]);
  13.   }
  14.  
  15.   for(int i=0;i<m;i++){
  16.     scanf("%lld", &periodos[i]);
  17.     if(periodos[i]>eventos[0])continue;
  18.     if(gcd1%periodos[i]==0){
  19.       puts("YES");
  20.       printf("%lld %d\n", eventos[0],i+1);
  21.       return 0;
  22.     }
  23.   };
  24.  
  25.   puts("NO");
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top