大学生程序代写

/*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. WPF 获取控件模板中的控件

    DG是控件名称public T GetVisualChild<T>(DependencyObject parent, Func<T, bool> predicate) wher ...

  2. 使用google的GSON解析json格式的数据

    GSON是谷歌提供的开源库,用来解析Json格式的数据,非常好用.如果要使用GSON的话,则要先下载gson-2.2.4.jar这个文件,如果是在Android项目中使用,则在Android项目的li ...

  3. amoeba安装与简单使用(一)

    1.我的环境Amoeba 2.0.1 -- CentOS release 6.8 (Final) -- 10.20.49.254Mysql 5.1.73 -- CentOS release 6.4 ( ...

  4. iOS NSError HTTP错误码大全

    NSError codes in the Cocoa error domain. enum { NSFileNoSuchFileError = 4, NSFileLockingError = 255, ...

  5. 15.Django添加一个功能模块的步骤(和SpringMVC类比)

    这里介绍如何在Django里新建一个模块,这个例子还是最简单的例子 通过浏览器访问 http://localhost:8000/hello/然后返回一个欢迎页 我是做java web出身的,这里用py ...

  6. GPS数据转换为OneNet需要的数据

    GPS的数据格式是DDMM.MMMMMM 获取到的GPS帧数据比如是:$GNRMC,112317.000,A,3438.1633,N,11224.4992,E,0.19,186.95,240916,, ...

  7. memset使用

    void memset(void s, int ch, size_t n); 函数解释:将s中当前位置后面的n个字节 (typedef unsigned int size_t )用 ch 替换并返回 ...

  8. sqlalchemy——基本操作

    以下所有代码片段都使用了统一的引用,该引用如下: from sqlalchemy import create_engine, ForeignKey from sqlalchemy.ext.declar ...

  9. 2django 视图与网址进阶

    一.在网页中做加减法 采用/add/?a=11&b=22这样get方法进行 django-admin.py startproject zqxt_views cd zqxt_views pyth ...

  10. 一看就懂的数据库范式介绍(1NF,2NF,3NF,BC NF,4NF,5NF)

    原文:http://josh-persistence.iteye.com/blog/2200644 一.基本介绍 设计关系数据库时,遵从不同的规范要求,设计出合理的关系型数据库,这些不同的规范要求被称 ...