2 条题解

  • 1
    @ 2023-4-16 11:26:41
    #include <iostream>
    using namespace std;
    
    bool isPrime(int x)
    {
        if (x < 2) return false;
        for (int i = 2; i * i <= x; i++)
        {
            if (x % i == 0) 
                return false;
        }
        return true;
    }
    
    int main()
    {
        int n;
        cin >> n;
        int cnt = 0;
        for (int i = 11; i <= n; i++)
        {
            if (isPrime(i))
            {
                int res = 0, t = i;
                while(t > 0)
                {
                    res = res * 10 + t % 10;
                    t /= 10;
                }
                if (res == i && isPrime(res)) cnt++;   
            }
        }
        cout << cnt << endl;
        return 0;
    }
    
    • 0
      @ 2023-4-15 23:06:59
      #include <bits/stdc++.h>
      using namespace std;
      int x,y,z,r;
      int zs(int c){
      	for(int i = 2 ; i <= c - 1 ; i++){
      		if(c % i == 0) return 0;
      	}
      	return c;
      }
      int dd(int f){
          if(f == 11){
          	r = 11;
      	}
      	else if(f >= 100){
      		x = (f % 10) * 100;
          	y = (f - x / 100) % 100;
          	z = (f - x / 100 - y) / 100;
          	r = x + y + z;
      	}
      	else r = 0;
      	return r;
      }
      int main(){
      	int a,b,e,sum = 0;
      	cin >> a;
      	for(int i = 11 ; i <= a ; i++){
      		b = zs(i);
      		if(b == 0) continue;
      		e = dd(b);
      		if(e == b){
      			sum++;
      		}
      	}
      	cout << sum << endl;
      	return 0;
      }
      //11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,929
      • 1

      信息

      ID
      1891
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      (无)
      递交数
      437
      已通过
      58
      上传者