#25819: to:用迴圈寫的人


morrisddd (MORRIS 范智傑)


絕對超時,請用sum = (a-b)/2,在判斷四種能

 

#26203: Re:to:用迴圈寫的人


dfd8282@gmail.com (fishhh)


絕對超時,請用sum = (a-b)/2,在判斷四種能

 

我實測過了

其實並不會TLE

當然用公式解會快很多~

AC (0.7s, 340KB)

 

附上程式碼::

#include<iostream> using namespace std; int main(){ long long a,b,tot=0; cin>>a>>b; for(int i=a;i<=b;i++){ tot+=(i%2==0); } cout<<tot; }

#26204: Re:to:用迴圈寫的人


arief6499@gmail.com (Muhammad Arief)


絕對超時,請用sum = (a-b)/2,在判斷四種能

 

我實測過了

其實並不會TLE

當然用公式解會快很多~

AC (0.7s, 340KB)

 

附上程式碼::

#include using namespace std; int main(){ long long a,b,tot=0; cin>>a>>b; for(int i=a;i<=b;i++){ tot+=(i%2==0); } cout<<tot; }


good article, if you need information related to similar articles you can access it here - http://news.unair.ac.id/en/2021/03/15/covid-vaccines-able-to-neutralize-new-variant-virus/

#27060: Re:to:用迴圈寫的人


s010400@student.cysh.cy.edu.tw (許家維)


絕對超時,請用sum = (a-b)/2,在判斷四種能

 

我實測過了

其實並不會TLE

當然用公式解會快很多~

AC (0.7s, 340KB)

 

附上程式碼::

#include using namespace std; int main(){ long long a,b,tot=0; cin>>a>>b; for(int i=a;i<=b;i++){ tot+=(i%2==0); } cout<<tot; }

絕對超時,請用sum