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. lua基础知识笔记

    一.lua中的数据类型 1.数值 a = 1 b = 1.2 2.字符串 c = "hello world" 3.布尔 d = true f = false 4.表(Table) ...

  2. Linux设定IP地址

    下面这些内容是直接从其他地方扒拉过来的,后期根据自己使用情况修改补充 虚拟机的连接方式 1.NAT(网络地址转换,虚拟机可以上网,但不能和物理机通信)-----VMnet82.host only(主机 ...

  3. 【HNOI2008】玩具装箱TOY & 斜率优化学习笔记

    题目 P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为 \(1\cdots N\ ...

  4. MQTT 开源代理mosquitto的网络层封装相当sucks

    最近学习MQTT协议,选择了当前比较流行的MQTT Broker “mosquitto”,但是在阅读代码过程中发现其网络底层库封装的相当差劲. 对于MQTT协议的变长头长度的读取上,基本上采取每次一个 ...

  5. python--基础篇二

    一. 格式化输出 :name=input("name:") age=input("age:") hobby=input("hobbie:") ...

  6. Windows Server 2008 R2(x64) IIS7+PHP5(FastCGI)环境搭建

    相关软件下载: 1.PHP下载地址: http://windows.php.net/downloads/releases/php-5.4.4-nts-Win32-VC9-x86.zip 如果是win2 ...

  7. tensorflow学习笔记(1)-基本语法和前向传播

    tensorflow学习笔记(1) (1)tf中的图 图中就是一个计算图,一个计算过程.                                       图中的constant是个常量 计 ...

  8. 关闭电脑自带键盘(copy)

    用管理员身份运行cmd: 禁用笔记本键盘 sc config i8042prt start= disabled 启用笔记本键盘 sc config i8042prt start= auto

  9. postgres(pl/pgsql)

    复制后期看 https://www.cnblogs.com/stephen-liu74/archive/2012/06/06/2312759.html https://www.cnblogs.com/ ...

  10. 解决ecplise安装mybatipse插件时报找不到jar包的错

    在安装mybatipse插件的时候一直报这个错,脑袋疼,在网上搜了半天也没有结果,最后摸索了半天解决了,这里先贴一张图 1.先找到eclipse的安装目录,然后把相应的jar包拷到plugins里去, ...