大学生程序代写

/*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. Java对文件夹中的文件按修改时间排序

    import java.io.File; import java.util.Arrays; import java.util.Comparator; import java.util.Date; pu ...

  2. uiwebview 屏幕自适应 -- 根据 内容适应或者 webview适应

    #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UIWebViewDelegate,UISe ...

  3. iOS 富文本类库RTLabel

      本文转载至 http://blog.csdn.net/duxinfeng2010/article/details/9004749  本节关于RTLable基本介绍,原文来自 https://git ...

  4. 红米4A手机刷开发版rom并且获取root权限

    1 bl解锁 Critical partition flashing is not allowed就是因为没有bl解锁. 注册小米账号并且关联手机. 下载bl解锁工具 http://www.miui. ...

  5. MySQL一些常见查询方式

    1.查询端口号命令: show global variables like 'port'; 2.查看版本号: select version(); 3.查看默认安装的MySQL的字符集 show var ...

  6. python 发送邮件的两种方式【终极篇】

    一,利用python自带的库 smtplib简单高效 from email.mime.multipart import MIMEMultipart from email.mime.text impor ...

  7. MySQL的information_schema库

    information_schema数据库是MySQL自带的,它提供了访问数据库元数据的方式. 什么是元数据呢?元数据是关于数据的数据,如数据库名或表名.列的数据类型,或访问权限.有些时候用于表述该信 ...

  8. FOXMAIL提示容量满无法收邮件,清除旧邮件后还是无法收取,请问如何解决?

    FOXMAIL提示容量满无法收邮件,清除旧邮件后还是无法收取,请问如何解决? 2009-03-23 11:21包子燕  分类:网站使用 我清除了FOXMAIL所在的磁盘空间,共有12G,也删除了部分旧 ...

  9. onActivityResult方法不执行,什么原因?

    原因: public void OnOpenPlayersActivity(View view) {  Intent intent = new Intent();  intent.setClass(g ...

  10. Kindeditor 编辑区样式结构

    ke-container   ke-toolbar   ke-edit   ke-edit-iframe   ke-edit-area   ke-statusbar