12208-how Many ones Needed?
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=244&page=show_ problem&problem=3360
Water.
Complete code:
/*0.035s*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
ll c[31][31], sum;
int I, j, CNT;
void init ()
{for
(i = 0; i < ++i)
c[i][0] = c[i][i] = 1;
for (i = 2; i < n ++i) for
(j = 1; j < i; ++j)
c[i][j] = c[i-1][j-1] + c[i-1][j];
}
inline ll Calc (int n, bool yeah)
{
sum = CNT = 0;
for (i = to i >= 0;-i)
{
if (n & (1 << i))
{for
(j = 0; J <= i; ++j)
sum = C I [j] * (j + CNT);
++cnt
}
}
if (yeah) sum + = cnt;///The number n is also counted as return
sum;
}
int main ()
{
init ();
int A, b, cas = 0;
ll ans;
while (scanf ("%d%d", &a, &b), a | | b)
printf ("Case%d:%lld\n", ++cas, Calc (b, True)-Calc (A, false));
return 0;
}
Author: csdn Blog Synapse7
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/