原文地址:https://blog.csdn.net/qq_37632935/article/details/79465213

给你一个数n(n<=10^14),然后问n能用几个连续的数表示;

求出sum奇因子的个数 就是答案  用算术基本定理的代码求就好了  vis设置为bool的 要不会翻车。。 答案要减一 因为1不是奇数

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define rap(a, n) for(int i=1; i<=n; i++)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int primes[];
bool vis[maxn];
int ans = ;
void init()
{
mem(vis, );
for(int i=; i<maxn; i++)
{
if(vis[i]) continue;
primes[ans++] = i;
for(LL j=(LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
} int main()
{
init();
int T, kase = ;
cin>> T;
while(T--)
{
LL n, res = ;
cin>> n;
for(int i=; i<ans && primes[i]*primes[i] <= n; i++)
{
LL cnt2 = ;
while(n % primes[i] == )
{
n /= primes[i];
cnt2++;
}
if(cnt2 > && primes[i] % )
res *= (cnt2 + );
}
if(n > && n % )
{
res *= ;
}
printf("Case %d: %lld\n", ++kase, res - ); } return ;
}

Sum of Consecutive Integers LightOJ - 1278(推公式 数学思维)的更多相关文章

  1. Sum of Consecutive Integers

    Sum of Consecutive Integers 题目链接 题意 问N能够分解成多少种不同的连续数的和. 思路 连续数是一个等差数列:$$ \frac{(2a1 + n -1)n}{2} = T ...

  2. LightOj 1278 - Sum of Consecutive Integers(求奇因子的个数)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1278 题意:给你一个数n(n<=10^14),然后问n能用几个连续的数表示; 例 ...

  3. LightOJ 1278 - Sum of Consecutive Integers 分解奇因子 + 思维

    http://www.lightoj.com/volume_showproblem.php?problem=1278 题意:问一个数n能表示成几种连续整数相加的形式 如6=1+2+3,1种. 思路:先 ...

  4. 2017多校第7场 HDU 6128 Inverse of sum 推公式或者二次剩余

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6128 题意:给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/a ...

  5. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  6. LeetCode Sum of Two Integers

    原题链接在这里:https://leetcode.com/problems/sum-of-two-integers/ 题目: Calculate the sum of two integers a a ...

  7. POJ 2739 Sum of Consecutive Prime Numbers(尺取法)

    题目链接: 传送门 Sum of Consecutive Prime Numbers Time Limit: 1000MS     Memory Limit: 65536K Description S ...

  8. ACM:POJ 2739 Sum of Consecutive Prime Numbers-素数打表-尺取法

    POJ 2739 Sum of Consecutive Prime Numbers Time Limit:1000MS     Memory Limit:65536KB     64bit IO Fo ...

  9. 【leetcode74】Sum of Two Integers(不用+,-求两数之和)

    题目描述: 不用+,-求两个数的和 原文描述: Calculate the sum of two integers a and b, but you are not allowed to use th ...

随机推荐

  1. 18、Java线程面试题 Top 50

    Java线程面试题 Top 50 原文链接:http://www.importnew.com/12773.html   本文由 ImportNew - 李 广 翻译自 javarevisited.欢迎 ...

  2. Mac OS 上 VIM 8.0 安装体验

    VIM 8.0 赶在中秋前发布 The best way to install Vim on Unix is to use the sources. This requires a compiler ...

  3. Spark优化一则 - 减少Shuffle

    Spark优化一则 - 减少Shuffle 看了Spark Summit 2014的A Deeper Understanding of Spark Internals,视频(要***)详细讲解了Spa ...

  4. php开发文章发布示例(正则表达式实例开发)

    存档: post.php <form method="post" action="viewthread.php" target="_blank& ...

  5. 面试之HTTP基础(不断完善中)

    目录 1. HTTP状态码 2.Cookie和Session Cookie Session 3.短连接与长连接 4.HTTPs 加密 5.Http和https的区别 6.HTTP/1.0 与 HTTP ...

  6. Visual Studio 设置C#语言代码格式

    设置代码大括号不另起一行: 工具 -> 选项 -> 文本编辑器 -> C# -> 代码样式 -> 格式设置

  7. “错误: 编码GBK的不可映射字符” 的解决方案

    命令行下,用javac命令编译java程序时,如果文档的编码为“utf-8”,并且含有中文字符时,会出现乱码现象,编译通过不了.如图: 解决方案:编译时指定编码方式,防止乱码.如下:

  8. 《图解 HTTP 》阅读 —— 第五章

    第5章 与HTTP协作的web服务器 一台服务器可以托管多个域名. 在相同的IP地址下,虚拟主机可以寄存多个不同主机名和域名的网站,所以在发送HTTP请求时,必须在Host首部内指定完整的主机名和域名 ...

  9. 基于腾讯云CLB实现K8S v1.10.1集群高可用+负载均衡

    概述: 最近对K8S非常感兴趣,同时对容器的管理等方面非常出色,是一款非常开源,强大的容器管理方案,最后经过1个月的本地实验,最终决定在腾讯云平台搭建属于我们的K8S集群管理平台~ 采购之后已经在本地 ...

  10. Web全景图的原理及实现

    全景图的基本原理 全景图是一种广角图.通过全景播放器可以让观看者身临其境地进入到全景图所记录的场景中去.比如像是这个.这种看起来很高大上的效果其实背后的原理并不复杂. 通常标准的全景图是一张2:1的图 ...