题目:

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. hdu_5969_最大的位或(贪心)

    题目链接:hdu_5969_最大的位或 题意: 中文,还是自己看 题解: xjb贪心一下就行了 #include<bits/stdc++.h> #define F(i,a,b) for(i ...

  2. 6、50道JAVA基础编程练习题跟答案

    50道JAVA基础编程练习题 [程序1] 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 程序分析 ...

  3. kettle连接Hive中数据导入导出(6)

    1.hive往外写数据 http://wiki.pentaho.com/display/BAD/Extracting+Data+from+Hive+to+Load+an+RDBMS 连接hive

  4. iOS 面试大全从简单到复杂(简单篇)

    1.UIWindow和UIView和 CALayer 的联系和区别? 答:UIView是视图的基类,UIViewController是视图控制器的基类,UIResponder是表示一个可以在屏幕上响应 ...

  5. erlang四大behaviour之一gen_server

      来源:http://www.cnblogs.com/puputu/articles/1701017.html erlang程序设计里面有个设计原则就是把你的进程构造成树,把共用代码提出来,特定功能 ...

  6. C# 在word文档中复制表格并粘帖到下一页中

    C# 在word文档中复制表格并粘帖到下一页中 object oMissing = System.Reflection.Missing.Value;            Microsoft.Offi ...

  7. 【洛谷P1352】没有上司的舞会

    [洛谷P1352]没有上司的舞会 x舷售 锚」翅θ 但是 拙臃 蓄ⅶ榔 暄条熨卫 翘ヴ馇 表现无愧于雪月工作室的核心管理 爸惚扎掬 颇瓶 芟缆肝 貌痉了 洵┭笫装 嗝◇裴腋 褓劂埭 ...

  8. swift UILable的用法

  9. 高效程序猿之 VS2010快速生成代码模板

    本文转载,原文地址 http://edi.wang/Post/2011/12/8/efficient-code-monkey-1-vs2010-generate-code-template 一只程序猿 ...

  10. VS中的快捷键快速格式化代码,使好看,整齐

    在VC2005中,快捷键是Ctrl + K, Ctrl + F, 这是一个组合键,即先按Ctrl + K, 这时候编辑器会等待下一个按键动作,此时再按Ctrl + F, 即可以格式化代码了,当然,也可 ...