大学生程序代写

/*A problem is easy

时间限制:1000 ms  |  内存限制:65535 KB

难度:3

描述

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 ?

输入

The first line contain a T(T <= 2000) . followed by T lines ,each line contain an

integer N (0<=N <= 10^11).

输出

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

样例输入

2

1

3

样例输出

0

1

上传者

苗栋栋*/





/*

双重循环肯定超时的 直接用一个判断条件能减少时间





i*j+i+j =N 经过观察,可以变形为i*j+i+j+1=N+1,也就是说,可以进一步变形为(i+1)*(j+1)=N+1





所以i从2判断到sqrt(n+1)即可

*/

#include<stdio.h>

#include<math.h>//不需要long long int

int main(){

   int m,i;

   scanf("%d",&m);

   while(m--){

int n;

   scanf("%d",&n);

int count = 0;

int s=sqrt(n+1);

for(i=2;i<=s;++i)

{

 if((n +1)%i==0)

 count++;

}

printf("%d\n",count);

}



return 0;

}

作者:chao1983210400 发表于2013-7-20 12:33:26 原文链接
阅读:12 评论:0 查看评论

[原]NYOJ-216-A problem is easy的更多相关文章

  1. nyoj 216-A problem is easy ((i + 1) * (j + 1) = N + 1)

    216-A problem is easy 内存限制:64MB 时间限制:1000ms 特判: No 通过数:13 提交数:60 难度:3 题目描述: When Teddy was a child , ...

  2. ACM A problem is easy

    A problem is easy 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 When Teddy was a child , he was always th ...

  3. [原]NYOJ 括号匹配系列2,5

    本文出自:http://blog.csdn.net/svitter 括号匹配一:http://acm.nyist.net/JudgeOnline/problem.php?pid=2 括号匹配二:htt ...

  4. A problem is easy

    描述When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’ ...

  5. nyoj A+B Problem IV

    A+B Problem IV 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 acmj最近发现在使用计算器计算高精度的大数加法时很不方便,于是他想着能不能写个程序把这 ...

  6. NYOJ 219 An problem about date

    An problem about date 时间限制:2000 ms  |  内存限制:65535 KB 难度:2   描述 acm的iphxer经常忘记某天是星期几,但是他记那天的具体日期,他希望你 ...

  7. nyoj 803-A/B Problem

    803-A/B Problem 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:4 难度:3 题目描述: 做了A+B Problem,A/B Problem不是什么问题了 ...

  8. nyoj 844-A+B Problem(V) (string[::-1] 字符串反转)

    844-A+B Problem(V) 内存限制:64MB 时间限制:1000ms 特判: No 通过数:14 提交数:17 难度:1 题目描述: 做了A+B Problem之后,Yougth感觉太简单 ...

  9. nyoj 513-A+B Problem IV (java BigDecimal, stripTrailingZeros, toPlainString)

    513-A+B Problem IV 内存限制:64MB 时间限制:1000ms 特判: No 通过数:1 提交数:2 难度:3 题目描述: acmj最近发现在使用计算器计算高精度的大数加法时很不方便 ...

随机推荐

  1. 毕达哥拉斯三元组(勾股数组)poj1305

    本原毕达哥拉斯三元组是由三个正整数x,y,z组成,且gcd(x,y,z)=1,x*x+y*y=z*z 对于所有的本原毕达哥拉斯三元组(a,b,c) (a*a+b*b=c*c,a与b必定奇偶互异,且c为 ...

  2. Collective Mindsets (easy)(逻辑题)

    Collective Mindsets (easy) Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d &am ...

  3. RMQ with Shifts(线段树)

    RMQ with Shifts Time Limit:1000MS     Memory Limit:65535KB     64bit IO Format:%I64d & %I64u Pra ...

  4. EasyDarwin开源流媒体服务器Golang版本:拉转推功能之拉流实现方法

    EasyDarwin开源流媒体服务器(www.easydarwin.org),拉转推是一个很有意义的功能,它可将一个独立的RTSP数据源"拉"到服务器,再通过转发协议转发给多个客户 ...

  5. 九度OJ 1251:序列分割 (DFS)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:166 解决:34 题目描述: 一个整数数组,长度为n,将其分为m份,使各份的和相等,求m的最大值   比如{3,2,4,3,6} 可以分成{ ...

  6. UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-3: ordinal not in range(256)

    今天使用MySQLdb往MySQL插入中文数据遇到一个异常: UnicodeEncodeError: 'latin-1' codec can't encode characters in positi ...

  7. 隐藏c语言烦人的{ }

    .vimrc文件中添加 autocmd BufNewFile,BufRead * :syn match braces conceal "[{}]" set conceallevel ...

  8. P3338 [ZJOI2014]力(FFT)

    题目 P3338 [ZJOI2014]力 做法 普通卷积形式为:\(c_k=\sum\limits_{i=1}^ka_ib_{k-i}\) 其实一般我们都是用\(i=0\)开始的,但这题比较特殊,忽略 ...

  9. PHP常用正则验证

    手机号,身份证,ip验证 //正则验证手机号 正确返回 true function preg_mobile($mobile) { if(preg_match("/^1[34578]\d{9} ...

  10. LINQ 学习路程 -- 查询操作 Quantifier Operators All Any Contain

    Operator Description All 判断所有的元素是否满足条件 Any 判断存在一个元素满足条件 Contain 判断是否包含元素 IList<Student> studen ...