hdu 2601
来源:互联网 发布:java获取编码方式 编辑:程序博客网 时间:2024/06/08 16:39
An easy problem
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5693 Accepted Submission(s): 1391
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 ?
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
213
Sample Output
01
Author
Teddy
Source
HDU 1st “Vegetable-Birds Cup” Programming Open Contest
其实这个问题还是比较水的,思路其实不难,但是想要将其做出来并不是件容易的事情,i+j+i*j=n,(i+1)*(j+1)=n+1,求出有多少对i,j,其实就是再n+1求有多少个解罢了,所以,直接挨个判断就是了
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){ int i,j,k; __int64 n; int g; int t; scanf("%d",&t); while(t--) { scanf("%I64d",&n); n++; //printf("%d\n",n); g=(int)sqrt((double)n); int sum=0; for(i=2;i<=g;i++) { if(n%i==0) { sum++; } } printf("%d\n",sum); } return 0;}
Recommend
lcy
0 0
- hdu 2601
- hdu 2601
- hdu 2601
- HDU 2601
- HDU 2601
- 【HDU 2601 】
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- C++中数字与字符串之间的转换
- 浅谈 C++ 中的 new/delete 和 new[]/delete[]
- 设计模式学习1——简单工厂模式
- html总结
- 学习
- hdu 2601
- bitset实现(转)
- Java文件file操作总结
- linux内核设计与实现第三章
- linux查看发行版本
- 002_026 Python 从OpenOffice.org的文档中提取文本
- 内存结构理解
- html
- 黑马程序员_面向对象01