Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:试了从1到10000,和另外一个AC的程序输出一模一样,二进制比较的,怎么我的总是WA??In Reply To:试了从1到10000,和另外一个AC的程序输出一模一样,二进制比较的,怎么我的总是WA?? Posted by:ivorstar at 2009-02-16 22:24:38 > 总是WA,谁给看看哪错了? > #include <iostream> > > using namespace std; > > int calcCoins(int days); > > int main() > { > int days; > > while(cin >> days && days) > { > cout << days << " " << calcCoins(days) << endl; > } > } > > int calcCoins(int days) > { > int i, sum = 0, r = 0; > for(i = 1; i <= days; i++) > { > sum = i * (i + 1) / 2; > if(sum > days) > break; > } > > for(int j = 1; j < i; j++) > { > r += j * j; > } > > r += i * (days + i - sum); > > return r; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator