1. 程式人生 > >An easy problem HDU 2132

An easy problem HDU 2132

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 <= 10 10).
Output
For each case, output the number of ways in one line.
Sample Input
2
1
3
Sample Output
0

1

思路:可以轉化為n+1=(i+1)*(j+1);

#include<stdio.h>
#include<math.h>
int main()
{
	int T,ans;
	long long i,a,b;
	scanf("%d",&T);
	while(T--)
	{
		ans=0;
		scanf("%lld",&a);
		a=a+1;
		b=sqrt(a);
		for(i=2;i<=b;i++)
		{
			if(a%i==0)
			ans++;
		} 
		printf("%d\n",ans);
	}
	return 0;
} 


相關推薦

An easy problem HDU 2132

Description When Teddy was a child , he was always thinking about some simple math problems ,such as

An easy problem HDU

題意 計算器初始值為1,只能進行 乘,除操作。 當x=1時,乘以y 當x=2時,除以第 y 次操作(第y次操作肯定是乘,x=1)所乘的數。 輸出的結果是對M取餘後的結果 思路 建樹時,將每一個節點初始化為1。假如第 J次操作,x=1 就將 [J,J]區間所在葉子結

hdu 2601 An easy problem

cto while using ble view -m pos pen add #include <stdio.h> #include <string.h> #include <iostream> #include &

hdu-5475 An easy problem---線段樹+取模

每一個 fin const lag update 結果 void 區間 hdu 題目鏈接: http://acm.hdu.edu.cn/showproblem.php?pid=5475 題目大意: 給X賦初值1,然後給Q個操作,每個操作對應一個整數M; 如果操作是1則將X乘

HDU 2055 - An easy problem

An easy problem Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 30364&n

HDU - 2055——An easy problem

An easy problem Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 33073 Accepted Submission(s)

hdu 5475 An easy problem (線段樹)

題意: 給定一個x,初值為1 有以下兩種操作: 1、乘以k 2、除以第k次操作的所乘的值 線段樹單點更新問題,查詢的時候只需要輸出v[1]的值即可。 具體看下程式碼就好了。 另外,這題xjb暴力可以卡時過掉,親測。 (其實本來並不想寫這個題解,這題真的是An easy

An Easy Problem

include 一個 限制 enter size 時間 輸出 tdi eas 鏈接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1223時間限制: 1000 ms 內存限制: 65536 KB 【題目描

POJ2826:An Easy Problem?!——題解(配特殊情況圖)

while 一次 mes bsp print 情況下 queue blank using http://poj.org/problem?id=2826 題目大意:給兩條線,讓它接豎直下的雨,問其能裝多少橫截面積的雨。 ———&mdas

An easy problem (位運算)

amp using lowbit bsp 找到 要求 位置 return 代碼 【題目描述】     給出一個整數,輸出比其大的第一個數,要求輸出的數二進制表示和原數二進制表示下1的個數相同。 【題目鏈接】     http://noi.openjudge.cn/ch040

POJ 2453 An Easy Problem G++

#include <iostream> #include <bitset> #include <vector> using namespace std; int main() { vector<int> jg; while(1) { bi

【HDU2601】An easy problem(思維)

題目連結 An easy problem Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm

poj 2826 An Easy Problem?! (變態卡資料題)

題目連結:poj 2826 題意:給出兩條直線,水從天上落下,問:這兩條直線組成的平面容器能裝多少水? 題解:很gou的題,超級變態卡資料,艹,足足搞了我幾天,總算搞出來了。 參考連結:https://www.cnblogs.com/kuangbin/p/3192511.html&n

A. In Search of an Easy Problem

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output When preparing a tour

Elimination Round 1.A. In Search of an Easy Problem

A. In Search of an Easy Problem time limit per test 1 second memory limit per test 256 megabytes input standard input output stand

POJ 2826 An Easy Problem?! 叉積求多邊形面積 【計算幾何】

An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7837 Accepted: 1145 Description It's

POJ 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

線段樹:CDOJ1591-An easy problem A (RMQ演算法和最簡單的線段樹模板)

An easy problem A Time Limit: 1000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Problem Description N個數排

poj 2826 An Easy Problem?! (線段相交判定)

An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12946 Accepted: 1988 Description It's raining outside

線段樹:CDOJ1592-An easy problem B (線段樹的區間合併)

An easy problem B Time Limit: 2000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Problem Description N個數