大学生程序代写

/*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. ASP.NET动态网站制作(17)-- C#(1)

    前言:用C#也有一年多了,基本上都是边用边学的,现在可以跟着老师系统的学习一下,感觉应该挺好的. 内容: 1.网站部署的相关内容:  (1)想要做一个网站,首先得去买一个域名,老师的域名是在美橙上买的 ...

  2. 几种动态调用js函数方案的性能比较

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 【python】-- 继承式多线程、守护线程

    继承式多线程 1.定义 继承式多线程是自己自定义类,去继承theading.Tread这个类,通过类实例.start()启动,去执行run方法中的代码. import threading import ...

  4. JVM垃圾回收时的可触及性

    可触及的 1.从根节点可以触及到这个对象可复活的 1.一旦所有引用被释放,就是可复活状态 2.因为在finalize()中可能复活该对象不可触及的 1.在finalize()后,可能会进入不可触及状态 ...

  5. centos7.0下删除yum和python之后恢复的办法

    centos 7如果卸载了yum和python之后恢复的办法(该方法已经测试). 下载 地址 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下 ...

  6. ubuntu sudo-update出错Encountered a section with no Package: header

    Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with Mer ...

  7. Yii2 提供可以用属性的方式去获取类的一个方法

    刚开始用 Yii 的小朋友可能对下面的写法非常疑惑: public function actionIndex() { $user = User::find()->where(['name'=&g ...

  8. linux shell 基础 使用日志与心得

    linux shell 基础 使用日志与心得 1.#!/bin/bash 第一行就出现#!/bin/bash是指此脚本使用/bin/bash来解释执行.其中,#!是一个特殊的表示符,其后,跟着解释此脚 ...

  9. 3.16课·········C#小结

    //附加//C#源码,被C#编译器,编译成执念代码(IL)//int16=short.....±32000//int32=int.......±21亿//int64=long......±922亿亿3 ...

  10. 让你快速上手Runtime(转)

    前言 本篇主要介绍Runtime在开发中的一些使用场景,顺便讲解了下MJExtension的底层实现.如果喜欢我的文章,可以关注我微博:袁峥Seemygo,也可以来小码哥,了解下我们的iOS培训课程. ...