#7167: C++WA LINE1輸出短少


y30103123 (fishman)


#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int a,b,n;
    bool k;
    while(cin>>a>>b&&a>=1&&b-a<1001&&b>=a&&b<=1000000)
    {
        n=0;
        for(int i=a; i<=b; i++)
        {
            k=true;
            for(int j=2; j<=sqrt(i); j++)
            {
                if(i%j==0)
                {
                    k=false;
                    break;
                }
            }
            if(k)
            {
                n=n+1;
            }
        }
        if(a==1)
        {
            cout<<n-1<<endl;
        }
        else
            cout<<n<<endl;
    }
    return 0;
}

執行都正確,但是都輸出短少~無解~"~
#7168: Re:C++WA LINE1輸出短少


y30103123 (fishman)



a>=1&&b-a<1001&&b>=a&&b<=1000000

這段刪除就正確了= ="
原來範圍不用設