码迷,mamicode.com
首页 >  
搜索关键字:uva10025    ( 3个结果
UVa10025 The ? 1 ? 2 ? ... ? n = k problem
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obta ...
分类:其他好文   时间:2017-04-13 00:45:12    阅读次数:164
UVa10025-The ? 1 ? 2 ? ... ? n = k problem
分析:因为数字之间只有加减变换,所以-k和k是一样的,都可以当成整数来考虑,只要找到最小的n满足sum=n*(n+1)/2>=k;且sum和k同奇同偶即可,做法是用二分查找,然后在就近查找因为1,2,3,4,5,6……的sum变化是奇奇偶偶奇奇偶偶奇奇偶偶……程序: 1 import java.ma...
分类:其他好文   时间:2015-08-12 18:57:39    阅读次数:97
uva10025 The ? 1 ? 2 ? ... ? n = k problem
10025 The ? 1 ? 2 ? … ? n = k problem Given the following formula, one can set operators ‘+’ or ‘-’ instead of each ‘?’, in order to obtain a given k ?1?2?…?n = k For example: to obtain k = 12, the e...
分类:其他好文   时间:2015-07-06 14:21:12    阅读次数:118
3条  
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!