大学生程序代写

/*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. php编译参数选项 具体参数含义可以用./configure --help来查看

    php编译参数选项  PHP_INSTALL_PATH=/data/web/php MYSQL_INSTALL_PATH=/data/web/mysql ./configure --prefix=${ ...

  2. poj2075

    Tangled in Cables Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6348   Accepted: 2505 ...

  3. 在VS2017环境中编译libxml2库

    libxml2库编译 1.下载libxml2,官网是:http://www.xmlsoft.org/downloads.html, 我下载的版本是:libxml2-sources-2.9.7.tar. ...

  4. python三大器

    装饰器 装饰器的作用: 装饰器的本质:一个闭包函数 (高阶函数+嵌套函数) 装饰器的功能:在不修改原函数及其调用方式的情况下对原函数功能进行扩展 闭包原理 装饰器执行流程 带多个参数函数 import ...

  5. spring jdbcTemplate的CRUD操作

    一.jdbcTemplate准备 1.导入与jdbcTemplate相关的jar包 2.设置数据库信息 3.创建jdbcTemplate对象,设置数据源 二.添加操作 1.代码 2.结果 三.修改操作 ...

  6. ABAP制作密码输入框

    [转自 http://blog.csdn.net/saphome/article/details/6956911] 这几天做一个系统维护的程序,需要用户输入用户名和密码登录.可怎样实现输入密码显示星号 ...

  7. PHP网页导出Word文档的方法分离

    今天要探讨的是PHP网页导出Word文档的方法,使用其他语言的朋友也可以参考,因为原理是差不多的. 原理 一般,有2种方法可以导出doc文档,一种是使用com,并且作为php的一个扩展库安装到服务器上 ...

  8. swift 全局常量 && 全局变量的写法

    在OC里面 如果 想设置一个全局常量 很简单 使用简单宏定义  就搞定了 例如: #define    WEBAPIBASEURL  @"http://www.baidu.com/" ...

  9. MySQL 创建索引(Create Index)的方法和语法结构及例子

    MySQL 创建索引(Create Index)的方法和语法结构及例子 MySQL 创建索引(Create Index)的方法和语法结构及例子   CREATE INDEX Syntax CREATE ...

  10. RTMP & HLS

    一,直播云架构 2. RTMP 协议 RTMP(Real Time Messaging Protocol)是Adobe Systems公司为Flash播放器和服务器之间音频.视频和数据传输开发的开放协 ...