#7163: 誰可以告訴我為甚麼會RE?


sammmm955252 (☆星空★)


這是我的程式碼:

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
    long long int a,b,g;
    bool temp;
    while (cin >> g){
          long long int sum=0;
          long long int y;
          for(long long int i=0;i<g;i++){
          cin >> a >> b;
          for(y=a;y<=b;y++){
          temp = true;
          for (long long int i=2;i<=sqrt(y);i++){
                  if (y%i==0){ temp=false; break;}}
          if (temp==false||y==1)sum=sum+y;}
          printf("%d\n",sum);
          sum=0;}}}

我自己執行時沒問題。

實不知錯在哪裡,有誰可以幫幫我,謝謝!

#7533: Re:誰可以告訴我為甚麼會RE?


davistonyhsu (曉石之音)


這是我的程式碼:

#include
#include
#include
using namespace std;
int main()
{
    long long int a,b,g;
    bool temp;
    while (cin >> g){
          long long int sum=0;
          long long int y;
          for(long long int i=0;i          cin >> a >> b;
          for(y=a;y<=b;y++){
          temp = true;
          for (long long int i=2;i<=sqrt(y);i++){
                  if (y%i==0){ temp=false; break;}}
          if (temp==false||y==1)sum=sum+y;}
          printf("%d\n",sum);
          sum=0;}}}

我自己執行時沒問題。

實不知錯在哪裡,有誰可以幫幫我,謝謝!

同學...int main要記得return 0;喔= =