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

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
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 考驾照怕过不了怎么办 学车对车没感觉怎么办 居住证到期2个月怎么办 生育险差一个月怎么办 驾照扣了38分怎么办 新疆转入山东上学怎么办手续 驾照过日期换证怎么办 机动车被扣24分怎么办 车辆被扣24分怎么办 现在深圳牌十年老车怎么办? 护士证过期4年了怎么办 护士资格证延续注册过期了怎么办 护士资格证过期没注册怎么办 护士资格证注册时间过期怎么办 辅警体检视力不行怎么办 护士延续注册体检怀孕怎么办 护士资格证没有延续注册怎么办 申请信用卡没有座机号码怎么办 网上申请信用卡没有座机号码怎么办 我叫上门服务被骗了怎么办 上门服务被骗了3000多怎么办 微信被骗9000元怎么办 奥迪a8气囊灯亮怎么办 驾考站岗迟到了怎么办 老板欠员工工资不给怎么办 如果有一天我没头发了怎么办 苏州公积金密码忘了怎么办 科二考试第二把怎么办 科一老是记不住怎么办 科目二考试没去怎么办 网约车驾龄不到怎么办 科四预约不上怎么办 教练不退钱怎么办找谁 驾考出入证丢了怎么办 科二成绩单丢了怎么办 考驾照的准考证丢了怎么办 驾考预约去不了怎么办 科目一预约没去怎么办 打狂犬疫苗期间感冒了怎么办 公司社保欠费不交怎么办 25号社保不交怎么办欠费