cf 75 C(gcd)
来源:互联网 发布:小米f码淘宝骗局 编辑:程序博客网 时间:2024/05/16 11:17
链接:http://codeforces.com/problemset/problem/75/C
求出a,b的gcd c,求出c的因子,判断是否在区间中
#include <bits/stdc++.h>using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int arr[10000];int main(){ int a,b,c; scanf("%d%d",&a,&b); c=gcd(a,b); int cnt=0; for(int i=1;i*i<=c;i++) { if(c%i==0) { arr[cnt++]=i; if(c/i!=i) arr[cnt++]=c/i; } } int n; sort(arr,arr+cnt); scanf("%d",&n); while(n--) { int l,r,flag=0; scanf("%d%d",&l,&r); for(int i=cnt-1;i>=0;i--) { if(arr[i]>=l&&arr[i]<=r) { flag=1; printf("%d\n",arr[i]); break; } } if(!flag) puts("-1"); } return 0;}
0 0
- cf 75 C(gcd)
- cf 75c Modified GCD
- cf 798c Mike and gcd problem
- CF 803C Maximal GCD 枚举,构造
- CF#323-DIV2-C - GCD Table - 贪心GCD
- 【GCD PROBLEM】CF 16.C——Monitor
- CF#200 div2 C Rational Resistance(math gcd)
- CF 678C 暑假集训13(gcd,lcm)
- CF#798 C. Mike and gcd problem(思维)
- CF --- 798 C Mike and gcd problem 【思维】
- cf 582A GCD Table
- CF 271F,区间gcd
- CF-Marco and GCD Sequence
- CodeForces 75C Modified GCD
- Codeforces 75 C Modified GCD
- CF 338 D GCD Table(CRT)
- 【CF】【318div2C】【整数表示】【gcd】
- CF 573A(Bear and Poker-GCD)
- ORMLite笔记
- font 0/0 a
- form表单验证的第二种函数
- IOS Dev Intro - UISwitch
- 树莓派 GrovePi Raspberry Pi 3B 添加 Grove Pi 扩展
- cf 75 C(gcd)
- 路由器的几种访问方式
- MongoDB---前世今生
- iOS类别(Category)与扩展(Extension)
- 【Android】随便写写
- 资料链接简记
- MUI事件管理
- linux(Centos6)安装Redmine 2.2.1
- 解决网络请求json字符串乱码问题