-3
爲什麼我的代碼http://ideone.com/zm6hP7不能滿足所有測試用例中的問題https://www.hackerrank.com/contests/opc-a/challenges/infinite-series? 我已經下載不滿意的測試用例,仍然無法找到我的代碼中的任何問題....有人可以告訴我什麼問題是?部分提交黑客等級
#include<stdio.h>`
#define m 1000000007
int main()
{
long long int t;
scanf("%lld",&t);
for(long long int i=0;i<t;i++)
{
long long int l,r;
scanf("%lld %lld",&l,&r);
long long int x,y;
if(l%2==0)
x=(((l/2)%m)*((l-1)%m))%m;
else
x=((l%m)*(((l-1)/2)%m))%m;
if(r%2==0)
y=(((r/2)%m)*((r+1)%m))%m;
else
y=((r%m)*(((r+1)/2)%m))%m;
printf("%lld\n",y-x);
}
return 0;
}
謝謝GoodDeeds .....那正是問題所在 –