3 条题解

  • 1
    @ 2024-10-5 21:59:41
    #include <iostream>  
    #include <cmath>  
    using namespace std;  
    
    long long Prime(long long n) {  
        long long a = n;  
        while (a > 9) {  
            a /= 10;  
            n = (n * 10 + a % 10);  
        }  
        return n;  
    }  
    
    int main() {  
        long long t;  
        cin >> t;  
        long long n = Prime(t);  
        bool isPrime = true;  
    
        if (n < 2) {  
            isPrime = false;
        } else {
            for (long long j = 2; j <= sqrt(n); j++) {  
                if (n % j == 0) {  
                    isPrime = false;  
                    break;  
                }  
            }  
        }
    
        if (isPrime) {  
            cout << "prime\n";  
        } else {  
            cout << "noprime\n";  
        }  
    
        return 0;  
    }
    
    • 0
      @ 2024-10-9 22:03:42
      #include <stdio.h>
      int main()
      {
          long long T=0;
          scanf("%lld",&T);
          int p=1;
          long long x=T;
          
          while (T>=10){
          	int t=(T/10)%10;
          	x=x*10+t;
          	T/=10;
      	}
          for (int i=2;i<x/2;i++){
          	if (x%i==0){
          		p=0;
          		break;
      		}
      	}
      	if (p==1){
      		printf("prime");
      	}
      	else if (p==0) {
      		printf("noprime");
      	}
          return 0;
      }
      
      • 0
        @ 2024-10-9 16:40:40
        #include <bits/stdc++.h>
        using namespace std;
        #define ll long long
        
        void makehuiwen(ll &x)
        {
            ll t = x / 10;
            while (t)
            {
                ll s = t % 10;
                x = x * 10 + s;
                t /= 10;
            }
        }
        
        bool issushu(ll x)
        {
            for (int i = 2; i < x / 2; i++)
            {
                if (x % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
        
        int main()
        {
            ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
            ll x;
            cin >> x;
            makehuiwen(x);
            if (issushu(x))
            {
                cout << "prime";
            }
            else
            {
                cout << "noprime";
            }
            return 0;
        }
        
        • 1

        信息

        ID
        112
        时间
        1000ms
        内存
        256MiB
        难度
        7
        标签
        递交数
        131
        已通过
        27
        上传者