• 杭电2098


    此题是一道简单的程序应用题!!!注意如何求1~10000之间的素数即可!!!
    同时本题我使用了打表的方法,至于不打表的话会不会超时,我也没有测试,
    感兴趣的话!!你何以不打表试验一下!!哈!!
    最后祝你成功ac!!!

    #include<iostream>
    using namespace std;
    int data[10005]; 
     void f()
    {
     data[2]=1;
     for(int i=3;i<=10000;i++)
     {   int k=0;
      for(int j=2;j<i;j++)
           if(i%j==0)
        { data[i]=0;
        k=1;
        break;
        
        }
                      if(k==0)
       data[i]=1;
         }
    }

    int main()
    {
        int n;
       f();
     while(cin>>n&&n!=0)
     {
         int count=0;
      for(int i=2;i<=n/2;i++)
          if(data[i]==1&&(data[n-i]==1)&&i!=n-i)
        count++;
        cout<<count<<endl;
     }
     return 0;
    }

  • 相关阅读:
    luogu 2962 [USACO09NOV]灯Lights
    bzoj 1923
    bzoj 1013
    bzoj 3513
    bzoj 4259
    bzoj 4503
    CF 632E
    bzoj 3527
    bzoj 3160
    bzoj 2179
  • 原文地址:https://www.cnblogs.com/xiohao/p/2766966.html
Copyright © 2020-2023  润新知