题目:

Description

standard input/output
Statements

Given an integer n, find out number of ways to represent it as the sum of two or more integers ai with the next property: ratio ai / ai - 1is the same positive integer for all possible i > 1.

Input

Input consists of one integer n (1 ≤ n ≤ 105).

Output

Print one integer — number of representations.

Sample Input

Input
1
Output
0
Input
5
Output
2
Input
567
Output
21

Hint

In the first sample no such representation exists.

In the second sample there exist two representations:

  • 1 1 1 1 1, then q = 1.
  • 1 4, then q = 4.

题目大意:给出一个等比数列(至少连个元素)的和n,要求公比q为整数,求满足要求的等比数列的个数。

题目思路:Sn=a1*(1-q^n)/(1-q),枚举q的值,判断a1是否为整数,比较暴力……

 #include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<queue>
#include<math.h>
#define INF 0x3f3f3f3f
#define MAX 1000005
#define Temp 1000000000 using namespace std; int check(long long q,long long n)
{
long long a=q;
int ans=;
while(n*(q-)/(a-) >= )
{
if(n*(q-)%(a-)== && n*(q-)/(a-)>= && n*(q-)/(a-)<n)//判断a1是否为整数,且满足要求
ans++;
a*=q;
}
return ans;
} int main()
{
int n,sum;
sum=;
scanf("%d",&n);
for(int i=; i<n; i++)
{
if(n%i== && n/i>)
sum++;
}
for(int i=; i<n; i++)//枚举公比的值
{
sum+=check(i,n);
}
printf("%d\n",sum);
return ;
}

Gym 100917C Constant Ratio 数论+暴力的更多相关文章

  1. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  2. ACM: Gym 100935G Board Game - DFS暴力搜索

    Board Game Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u  Gym 100 ...

  3. Codeforces Gym 100513M M. Variable Shadowing 暴力

    M. Variable Shadowing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/ ...

  4. Codeforces Gym 100513G G. FacePalm Accounting 暴力

    G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513 ...

  5. Codeforces Gym 100002 C "Cricket Field" 暴力

    "Cricket Field" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1000 ...

  6. Codeforces Gym 100203G G - Good elements 暴力

    G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

  7. Codeforces Gym 100342E Problem E. Minima 暴力

    Problem E. MinimaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attac ...

  8. HDU 1333 基础数论 暴力

    定义一种数位simth数,该数的各位之和等于其所有质因子所有位数字之和,现给出n求大于n的最小该种数,n最大不超过8位,那么直接暴力就可以了. /** @Date : 2017-09-08 14:12 ...

  9. UVA 617 - Nonstop Travel(数论+暴力枚举)

    题目链接:617 - Nonstop Travel 题意:给定一些红绿灯.如今速度能在30-60km/h之内,求多少个速度满足一路不遇到红灯. 思路:暴力每个速度,去推断可不能够,最后注意下输出格式就 ...

随机推荐

  1. 前台javascript排序

    <script type="text/javascript"> $(function () { $('.Sorthead-ShowUp').click(function ...

  2. Struts入门学习(三)---自定义类型转换器

    类型转换器是将浏览器传递的参数进行转换为了与服务器端的参数匹配,先举个例子如果我们想往服务器传递日期类型的参数时我们要怎么让浏览器传过去的让服务器明白 我们新建一个类 ConverterTest.ja ...

  3. marble 基本函数(一)

    . 标记 GeoDataPlacemark *place = new GeoDataPlacemark( "Bucharest" ); place->setCoordinat ...

  4. Linux中如何设置java环境变量

    这里介绍Linux下如何设置java环境变量. 工具/原料 Linux java环境变量 方法/步骤 1 查看java的安装路径   查看java执行路径   配置java环境变量   java的安装 ...

  5. docker的一些命令

    转自:http://blog.csdn.net/wsscy2004/article/details/25878363 查看容器的root用户密码 docker logs <容器名orID> ...

  6. ios中判断当前手机的网络状态

    typedef enum {    NETWORK_TYPE_NONE= 0,    NETWORK_TYPE_2G= 1,    NETWORK_TYPE_3G= 2,    NETWORK_TYP ...

  7. 灰色关联度Matlab代码

    load x.txt %把原始数据存放在纯文本文件x.txt中,其中把数据的"替换替换成. for i=1:40x(i,:)=x(i,:)/x(i,1); %标准化数据end data=x; ...

  8. [转载]Winform中Control的Invoke与BeginInvoke方法

    转自http://www.cppblog.com/baby-fly/archive/2010/04/01/111245.html 一.为什么 Control类提供了 Invoke和 BeginInvo ...

  9. 欧几里得算法求最大公约数(gcd)

    关于欧几里得算法求最大公约数算法, 代码如下: int gcd( int a , int b ) { if( b == 0 ) return a ; else gcd( b , a % b ) ; } ...

  10. web.config中httpModules和Modules的区别

    最近用到了mvc的 Modules管道时,发现web.config中有两个modules 1.system.web节点下的httpModules 2.system.webServer节点下的modul ...