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. MD5、SHA校验命令

    linux系统的软件很多时候都以境像的方式提供下载,但我们如何确实下载的文件是没有被篡改过的呢?Linux中一般用对下载的文件进行MD5和SHA校验来确认. MD5 我们拿iptraf软件来试验: 我 ...

  2. Vm Ubuntu 文件共享问题

    其实也是差不多的,就是需要重新安装一次工具 ,自己安装有问题,自己在手动安装一次就好了 下面是一个我的参考文章 http://blog.csdn.net/zz962/article/details/7 ...

  3. Sleuth+Zipkin+Log

    https://blog.csdn.net/sqzhao/article/details/70568637 https://blog.csdn.net/yejingtao703/article/det ...

  4. 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 ...

  5. 为什么logstash进程的CPU使用率100%?

    机器上有个进程cpu使用率很高,近100%了, Tasks: 120 total, 2 running, 118 sleeping, 0 stopped, 0 zombie%Cpu(s): 99.0 ...

  6. Cross Entropy in Machine Learning

    整理摘自:https://blog.csdn.net/tsyccnh/article/details/79163834 信息论 Outline 1. 信息量与信息熵 2. 相对熵(KL散度) 3. 交 ...

  7. EM算法浅析(一)-问题引出

    EM算法浅析,我准备写一个系列的文章: EM算法浅析(一)-问题引出 EM算法浅析(二)-算法初探 一.基本认识 EM(Expectation Maximization Algorithm)算法即期望 ...

  8. nvm版本管理工具安装

    windows 安装nvm步骤(shi'yongnvm-windows管理node版本): 瞎几把前言:mac上可以用n来管理node版本,私以为n很好用.家里的win7台式机一直没有安装过任何管理工 ...

  9. DFS(8)——poj2034Anti-prime Sequences

    一.题目回顾 题目链接:Anti-prime Sequences Sample Input 1 10 2 1 10 3 1 10 5 40 60 7 0 0 0   Sample Output 1,3 ...

  10. OO5-7次作业总结

    写在最前面: 转眼间就又到了一月一次的总结时间,这次的三个作业,我个人感觉可能是最令人难受的三次作业了.不只是因为它们是多线程,更是因为它们几乎是全新的三次作业,每次的代码几乎都要重头开始. 第五次作 ...