An easy problem

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 <= 10 10).

Output

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

Sample Input

2
1
3

Sample Output

0
1
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int ans=0;
		long long N;
		scanf("%lld",&N);
		/*for(int i=1;(i+1)*(i+1)<=(N+1);i++)
		{
			if(((N-i)%(i+1)==0)&&((N-i)/(i+1)>=i))
				ans++;
		}*/
		for(long long i=1;(i+1)*(i+1)<=(N+1);i++)
		{
			if((N+1)%(i+1)==0&&((N-i)/(i+1)>=i))
				ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
 } 
时间: 2024-10-15 16:55:37

An easy problem的相关文章

an easy problem(贪心)

An Easy Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8333   Accepted: 4986 Description As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.

HDU2123 An easy problem【水题】

An easy problem Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5922    Accepted Submission(s): 4122 Problem Description In this problem you need to make a multiply table of N * N ,just like th

HDU2132 An easy problem【水题】

An easy problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10149    Accepted Submission(s): 2689 Problem Description We once did a lot of recursional problem . I think some of them is easy

poj2826An Easy Problem?!

链接 繁琐细节题. 1.线段无交点时,ans=0; 2.如图 假设过p3.y的水平线与p1p2相交 因为雨是垂直下落的,左图的情况是无法收集到雨水的 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<vector> 7 #include<cmath&g

Poj 2826 An Easy Problem?!

地址:http://poj.org/problem?id=2826 题目: An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13016   Accepted: 2003 Description It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails tw

FZU 1753-Another Easy Problem(求多个组合数的最大公约数)

Another Easy Problem Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 1753 Appoint description:  xietutu  (2013-03-13)System Crawler  (2015-04-27) Description 小TT最近学习了高斯消元法解方程组,现在他的问题来了,如果是以下的方程,

(DS 《算法入门经典》)UVA 11991 Easy Problem from Rujia Liu?(求第k个v出现的索引)

题目大意: 求第k个v出现的索引 解题思路: 如果能构造出一个数据结构,使得data[v][k]就是第k个v出现的索引值即可求解.data[v]表示数v出现的索引数组, data[v][k]表示第k个v出现的索引. Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, regional contests like Xi'an 200

fzu 1753 Another Easy Problem

本题题意为求 t (t<150) 个 c (n,m)  (1<=m<=n<=100000)的最大公因子: 本题的难点为优化.主要有两个优化重点.一是每次对单个素因子进行处理,优化每次的数组清零:二是对求阶乘素因子个数的优化 ei=[N/pi^1]+ [N/pi^2]+ …… + [N/pi^n]  其中[]为取整 ei 为数 N!中pi 因子的个数: #include <iostream>#include <cstring>#include <cmat

POJ2826 An Easy Problem?!(线段交点,三角形面积)

题目链接: http://poj.org/problem?id=2826 题目描述: An Easy Problem?! Description It's raining outside. Farmer Johnson's bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn. Shown in the pictures below, the two b

HDU 5475An easy problem 离线set/线段树

An easy problem Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description One day, a useless calculator was being built by Kuros. Let's assume that number X is showed on the screen of calculator. At first