Title Link: http://lightoj.com/volume_showproblem.php?problem=1278
Test instructions: give you a number n (n<=10^14), then ask N can be expressed in several consecutive numbers;
For example: 15 = 7+8 = 4+5+6 = 1+2+3+4+5, so 15 corresponding answer is 3, there are three kinds;
We are now equivalent to known arithmetic progression and sum = N, the other first item is A1, Total m, then am = a1+m-1;
sum = m* (a1+a1+m-1)/2-----> a1 = sum/m-(m-1)/2
A1 and M must be integers, so sum%m = 0 and (m-1)%2=0, so M is the factor of sum, and if odd;
So we only ask for the number of the odd factor of N, and the number of factors is the number of all prime factors of the power +1, multiplied by, then only 2 of the primes are even,
So the number of odd factor is all the prime factor (except 2) +1 of the product, of course, M must be greater than 1, so subtract 1, remove factor 1 case;
'35; include <stdio.h>
'35; include <iostream>
'35; include <algorithm>
%35; include <string.h>
using namespace std;
typedef long long LL;
const double eps = 1e-10;
const int N = 1e7+1;
int p[N/10], k;
bool f[N];
void Init()
{
for(int i=2; i<N; i++)
{
if! f[i]) p[k++] = i;
for(int j=i+i; j<N; j+=i)
f[j] = true;
*
*
int main()
{
Init();
int T, t = 1;
scanf("%d", &T);
while(T --)
{
LL n, as = 1;
scanf("%lld", &n);
int flag = 0;
for(int i=0; i<k &&LL)p[i]*p[i]<=n; i++)
{
LL cnt = 0;
while(n%p[i] == 0)
{
cnt ++;
n /= p[i];
*
if(i)///19981;- 33021;- 31639; 2
ans *= cnt+1;
*
if(n > 2)
to *= 2;
ans -= 1;///20943;- 21435;- 1d209171;
printf("Case%d:%lld\n", t++, ans);
*
return 0;
*
View Code
Lightoj 1278-sum of consecutive integers (number of odd factors)