JHDU 2601 An easy problem (数学 )
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 (数学 )的更多相关文章
- 数学--数论-- HDU 2601 An easy problem(约束和)
Problem Description When Teddy was a child , he was always thinking about some simple math problems ...
- HDU 2601 An easy problem
(i+1)*(j+1)=n+1 转换成上面这个式子,也就是问n+1的因子有几个 #include<cstdio> #include<cstring> #include<c ...
- hdu2601 An easy problem(数学)
题目意思: http://acm.hdu.edu.cn/showproblem.php? pid=2601 给出一个数N,求N=i*j+i+j一共同拥有多少种方案. 题目分析: 此题直接暴力模拟就可以 ...
- D. Easy Problem dp(有衔接关系的dp(类似于分类讨论) )
D. Easy Problem dp(有衔接关系的dp(类似于分类讨论) ) 题意 给出一个串 给出删除每一个字符的代价问使得串里面没有hard的子序列需要付出的最小代价(子序列不连续也行) 思路 要 ...
- UVA-11991 Easy Problem from Rujia Liu?
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...
- An easy problem
An easy problem Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- 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, ...
- POJ 2826 An Easy Problem?!
An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7837 Accepted: 1145 ...
- hdu 5475 An easy problem(暴力 || 线段树区间单点更新)
http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...
随机推荐
- 【C#】 RBAC 权限框架
[C#] RBAC 权限框架 一. 名词解释 1. 用户 : 登录的账号, 和角色挂钩,可拥有多个角色 2. 角色 : 账号所属的角色, 和权限挂钩,可拥有多个权限 3. 权限 : 角色拥有的操作权限 ...
- Remote X11 GUI for Linux/Unix
摘自:https://www.redwireservices.com/remote-x11-for-linux-unix The Problem One of my most feared quest ...
- Django打造大型企业官网
第1章 Django预热 1-为什么需要虚拟环境 2-virtualenv创建虚拟环境 3-virtualenvwrapper使用 4-URL组成部分讲解 5-课程准备工作 6-Django介绍 第2 ...
- P2384洛谷 最短路
题目描述 给定n个点的带权有向图,求从1到n的路径中边权之积最小的简单路径. 输入输出格式 输入格式: 第一行读入两个整数n,m,表示共n个点m条边. 接下来m行,每行三个正整数x,y,z,表示点x到 ...
- c#form界面情况下显示console窗体
使用console.write()前后加上AllocConsole()和FreeConsole()方法. 注意:如果在使用之前有console输出(不带有这两个方法),则会无效. 这两个方法: [Dl ...
- 实现AJAX跨域访问方式一
1.添加pom依赖 <dependency> <groupId>com.thetransactioncompany</groupId> <artifactId ...
- Zebra - zebra command to get printer status
/// <summary> /// determine whether the network printer is in pause. /// </summary> /// ...
- systemtap如何写C函数 捎带着看看ret kprobe怎么用
在systemstap中自定义函数 Embedded C can be the body of a script function. Instead enclosing the function bo ...
- request.getParameterMap() 获取表单提交的键值对 并且 也能获取动态表单的key
Map<String,String[]> map = request.getParameterMap();Set<String> keys = map.keySet(); 获取 ...
- 深入理解Netscaler INat
深入理解Netscaler INat http://blog.51cto.com/caojin/1898173 Netscaler的INat主要是用作基于目的地址的转换,将client访问的公网IP通 ...