fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4.  
  5. int main(){
  6. int t,tt=1;
  7. cin>>t;
  8. while(t--){
  9. LL a,b,c;
  10. cin>>a>>b>>c;
  11. LL ar[b],ar1;
  12. for(LL i=0;i<b;i++){
  13. cin>>ar[i];
  14. }
  15. LL cnt,sum=0;
  16. for(LL i=0;i<c;i++){
  17. cin>>ar1;
  18. cnt=0;
  19. sum+=(a/ar1);
  20. for(LL j=0;j<b;j++){
  21. if(ar[j]%ar1==0) cnt++;
  22. }
  23. // cout<<sum<<" "<<cnt<<endl;
  24. sum-=cnt;
  25. }
  26. cout<<"Case #"<<tt++<<": "<<sum<<endl;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 4312KB
stdin
3
11 1 2
8
2 3
11 11 11
1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 8 9 10 11
1000 6 1
4 8 15 16 23 42
1
stdout
Case #1: 7
Case #2: 0
Case #3: 994