B - An easy problem
来源:互联网 发布:郭天祥51单片机pdf 编辑:程序博客网 时间:2024/05/22 22:41
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
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
输入n,计算有多少种i*j+i+j==n
#include <iostream>#include <cstring>#include <cstdio>#include<cmath>#include<algorithm>using namespace std;int main(){ int t; scanf("%d",&t); long long n; for(int k=0;k<t;k++) { cin>>n; n++; int m=(int)sqrt(n*1.0); int count=0; for(int i=2;i<=m;i++) { if(n%i==0) count++; } cout<<count<<endl; } return 0;}
0 0
- B - An easy problem
- B - An easy problem
- B - An easy problem
- UESTC 1592 An easy problem B 线段树区间合并
- An Easy Problem
- 2055 An easy problem
- An Easy Problem!
- An Easy Problem!
- poj2826 An Easy Problem?!
- HDOJ2055 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- hdu2601 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- HDU_2055 An easy problem
- HDU_2123 An easy problem
- An easy problem
- hdu——2603——Wiskey's Power
- Java中synchronized的使用
- SoftReference 内存缓存 和 listview 分页加载
- vs2008 试用版评估期结束的解决方法
- WPA-PSK/WPA2-PSK
- B - An easy problem
- 反素数 2521
- hdwiki模板用到的标签
- [2014-3-16]错误处理
- HDU 1285
- linux查找端口状态
- 操作系统作业管理
- iOS-Runtime-Headers
- 安装Eclipse Maven插件的几种方法