title: An easy problem 数学 杭电2601

tags: [数学]

题目链接

Problem Description

When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’s 1 cup of water plus 1 pile of dough ..” , “100 yuan buy 100 pig” .etc..

One day Teddy met a old man in his dream , in that dream the man whose name was“RuLai” gave Teddy a

problem :

Given an N , can you calculate how many ways to write N as i * j + i + j (0 < i <= j) ?

Teddy found the answer when N was less than 10…but if N get bigger , he found it was too difficult for him to solve.

Well , you clever ACMers ,could you help little Teddy to solve this problem and let him have a good dream ?

Input

The first line contain a T(T <= 2000) . followed by T lines ,each line contain an integer N (0<=N <= 1010).

Output

For each case, output the number of ways in one line.

Sample Input

2

1

3

Sample Output

0

1

分析:

注意到 ( i +1 ) * ( j + 1 ) = i * j + i + j + 1= n + 1;而且这里的 n 比较大,只能跑一层循环

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
LL n;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld",&n);
int ans=0;
for(LL i=2; i*i<=n+1; i++)
{
if((n+1)%i==0)
ans++;
}
printf("%d\n",ans);
}
return 0;
}

JHDU 2601 An easy problem (数学 )的更多相关文章

  1. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  2. HDU 2601 An easy problem

    (i+1)*(j+1)=n+1 转换成上面这个式子,也就是问n+1的因子有几个 #include<cstdio> #include<cstring> #include<c ...

  3. hdu2601 An easy problem(数学)

    题目意思: http://acm.hdu.edu.cn/showproblem.php? pid=2601 给出一个数N,求N=i*j+i+j一共同拥有多少种方案. 题目分析: 此题直接暴力模拟就可以 ...

  4. D. Easy Problem dp(有衔接关系的dp(类似于分类讨论) )

    D. Easy Problem dp(有衔接关系的dp(类似于分类讨论) ) 题意 给出一个串 给出删除每一个字符的代价问使得串里面没有hard的子序列需要付出的最小代价(子序列不连续也行) 思路 要 ...

  5. UVA-11991 Easy Problem from Rujia Liu?

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

  6. An easy problem

    An easy problem Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  7. UVa 11991:Easy Problem from Rujia Liu?(STL练习,map+vector)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  8. POJ 2826 An Easy Problem?!

    An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7837   Accepted: 1145 ...

  9. hdu 5475 An easy problem(暴力 || 线段树区间单点更新)

    http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...

随机推荐

  1. VM打开虚拟机文件报错

    用VM打开以前的虚拟机文件报错 Cannot open the disk 'F:/****.vmdk' or one of the snapshot disks it depends on. 这种问题 ...

  2. Smart Framework:轻量级 Java Web 框架

    Smart Framework:轻量级 Java Web 框架 收藏 黄勇   工作闲暇之余,我开发了一款轻量级 Java Web 框架 —— Smart Framework. 开发该框架是为了: 加 ...

  3. 「题目代码」P1034~P1038(Java)

    P1034 C基础-求同存异 import java.util.*; import java.io.*; import java.math.BigInteger; public class Main ...

  4. 自动化测试--testNG

    该文章主要介绍 testNG(testing next generation,下一代测试技术)框架的使用. 1.首先安装testNG 2.安装完成后,创建maven项目,导入TESTNG和seleni ...

  5. 第二篇 Postman的高阶使用之配置全局变量及局部变量的调用及设置方法(手动方法)

    第五篇主要写了关于postman的基本使用,重点是如果发送json请求,为什么要将发送json请求呢, 一是目前大多数的请求已经倾向于发送json格式,二是本人太懒了,不想一个字段一个字段的添加到参数 ...

  6. Sql面试题之三(难度:简单| 含答案)

    Sql面试题之三(难度:简单| 含答案) 答案: .SELECT B.name, B.Depart T.Content FROM B, T WHERE ( T.Content = '税法培训' and ...

  7. TensorFlow 调用预训练好的模型—— Python 实现

    1. 准备预训练好的模型 TensorFlow 预训练好的模型被保存为以下四个文件 data 文件是训练好的参数值,meta 文件是定义的神经网络图,checkpoint 文件是所有模型的保存路径,如 ...

  8. 基于规则的中文分词 - NLP中文篇

    之前在其他博客文章有提到如何对英文进行分词,也说后续会增加解释我们中文是如何分词的,我们都知道英文或者其他国家或者地区一些语言文字是词与词之间有空格(分隔符),这样子分词处理起来其实是要相对容易很多, ...

  9. 数论初步——Eratosthenes筛法

    具体内容见紫书p312-p313 一.用Eratosthenes筛法构造1~n的素数表 思想:对于不超过n的每个非负整数p,删除2p,3p,4p…,当处理完所有的数后,还没有被删除的就是素数. 代码: ...

  10. 最短路径——Bellman-Ford算法以及SPFA算法

    说完dijkstra算法,有提到过朴素dij算法无法处理负权边的情况,这里就需要用到Bellman-Ford算法,抛弃贪心的想法,牺牲时间的基础上,换取负权有向图的处理正确. 单源最短路径 Bellm ...