2 条题解

  • 2
    @ 2023-5-6 20:38:02
    #include<iostream>
    #include<algorithm>
    #define int long long
    using namespace std;
    signed main(){
    	int t;
    	cin>>t;
    	while(t -- ){
    		int n,m;
    		cin>>n>>m;
    		if(__gcd(n,m)==1){
    			cout<<"N\n";
    		}else{
    			cout<<"Y\n";
    		}
    	}
    	return 0;
    }
    
    • 0
      @ 2025-5-24 11:44:58
      #include <iostream>
      #include <algorithm> // 用于__gcd函数
      using namespace std;
      
      long long gcd(long long a, long long b) {
          while (b != 0) {
              long long temp = b;
              b = a % b;
              a = temp;
          }
          return a;
      }
      
      int main() {
          ios::sync_with_stdio(false);
          cin.tie(nullptr);
          
          int T;
          cin >> T;
          
          while (T--) {
              long long A, B;
              cin >> A >> B;
              
              if (gcd(A, B) > 1) {
                  cout << "Y\n";
              } else {
                  cout << "N\n";
              }
          }
          
          return 0;
      
      
      
      • 1

      信息

      ID
      2954
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      613
      已通过
      98
      上传者