题意:找到[a, b]的最大公约数;
思路:相同时为本身,不同时为1.
套路:碰到水题别想太多;
猜想:两个相邻数,必有一奇一偶,如果偶数有因子3或者其他,奇数可不可能有相同的呢?
枚举一些数后发现没有,出现的奇数全是素数。
1 #include <iostream> 2 #include <algorithm> 3 #include <stdlib.h> 4 #include <time.h> 5 #include <cmath> 6 #include <cstdio> 7 #include <string> 8 #include <cstring> 9 #include <vector> 10 #include <queue> 11 #include <stack> 12 #include <set> 13 14 #define c_false ios_base::sync_with_stdio(false); cin.tie(0) 15 #define INF 0x3f3f3f3f 16 #define INFL 0x3f3f3f3f3f3f3f3f 17 #define zero_(x,y) memset(x , y , sizeof(x)) 18 #define zero(x) memset(x , 0 , sizeof(x)) 19 #define MAX(x) memset(x , 0x3f ,sizeof(x)) 20 #define swa(x,y) {LL s;s=x;x=y;y=s;} 21 using namespace std ; 22 typedef long long LL; 23 const int N = 205; 24 25 char n[N], m[N]; 26 27 int main(){ 28 //freopen("in.txt","r",stdin); 29 //freopen("out.txt","w",stdout); 30 //ios_base::sync_with_stdio(false); cin.tie(0); 31 scanf("%s%s", n, m); 32 string n1, m1; 33 n1 = n; m1 = m; 34 if(n1 == m1) printf("%s\n", n); 35 else printf("1\n"); 36 return 0; 37 }