zoukankan      html  css  js  c++  java
  • D

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <iostream>
     4 #include <algorithm>
     5 #include <cmath>
     6 #include <vector>
     7 #include <set>
     8 #include <map>
     9 #include <time.h>
    10 using namespace std;
    11 
    12 typedef long long ll;
    13 
    14 vector<int> x;
    15 int L, R, A, B, N, m, ans;
    16 
    17 int main()
    18 {
    19 //    freopen("in.txt", "r", stdin);
    20 //    freopen("out.txt", "w", stdout);
    21 
    22     while(scanf("%d%d", &A, &B) == 2) {
    23         A = __gcd(A, B);
    24         B = sqrt(A);
    25         x.clear();
    26         for (int i = 1;i <= B;i++)
    27             if (A%i == 0) {
    28                 x.push_back(i);
    29                 x.push_back(A/i);
    30             }
    31 
    32         sort(x.begin(), x.end());
    33 
    34         scanf("%d", &N);
    35         //printf("%d! ", N);
    36         for (int i = 0;i < N;i++) {
    37             scanf("%d%d", &L, &R);
    38             m = upper_bound(x.begin(), x.end(), R) - x.begin() - 1;
    39             ans = x[m];
    40             if (L > ans) puts("0");
    41             else printf("%d ", ans);
    42             //if(i > 9600) printf("%d ", i);
    43         }
    44         printf(" ");
    45     }
    46     return 0;
    47 
    48 }
    View Code
  • 相关阅读:
    阿里云遇到的坑:CentOS7防火墙(Firewalld),你关了吗?
    阿里云学生机——Mysql配置---教小白入门篇
    关于Javac编译器的那点事(一)
    B树,B+树,B*树简介
    ArrayList动态扩容机制
    满二叉树和完全二叉树
    nginx实践(二)之静态资源web服务(浏览器缓存场景)
    http之cdn介绍
    http之理解304
    nginx实践(一)之静态资源web服务
  • 原文地址:https://www.cnblogs.com/acvc/p/4419838.html
Copyright © 2011-2022 走看看