[原]NYOJ-216-A problem is easy
/*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;
}
[原]NYOJ-216-A problem is easy的更多相关文章
- 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 , ...
- ACM A problem is easy
A problem is easy 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 When Teddy was a child , he was always th ...
- [原]NYOJ 括号匹配系列2,5
本文出自:http://blog.csdn.net/svitter 括号匹配一:http://acm.nyist.net/JudgeOnline/problem.php?pid=2 括号匹配二:htt ...
- A problem is easy
描述When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’ ...
- nyoj A+B Problem IV
A+B Problem IV 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 acmj最近发现在使用计算器计算高精度的大数加法时很不方便,于是他想着能不能写个程序把这 ...
- NYOJ 219 An problem about date
An problem about date 时间限制:2000 ms | 内存限制:65535 KB 难度:2 描述 acm的iphxer经常忘记某天是星期几,但是他记那天的具体日期,他希望你 ...
- nyoj 803-A/B Problem
803-A/B Problem 内存限制:64MB 时间限制:1000ms 特判: No 通过数:2 提交数:4 难度:3 题目描述: 做了A+B Problem,A/B Problem不是什么问题了 ...
- nyoj 844-A+B Problem(V) (string[::-1] 字符串反转)
844-A+B Problem(V) 内存限制:64MB 时间限制:1000ms 特判: No 通过数:14 提交数:17 难度:1 题目描述: 做了A+B Problem之后,Yougth感觉太简单 ...
- nyoj 513-A+B Problem IV (java BigDecimal, stripTrailingZeros, toPlainString)
513-A+B Problem IV 内存限制:64MB 时间限制:1000ms 特判: No 通过数:1 提交数:2 难度:3 题目描述: acmj最近发现在使用计算器计算高精度的大数加法时很不方便 ...
随机推荐
- 读《《图解TCP-IP》》有感
读<<图解TCP/IP>>有感 TCP/IP 近期几天读完<<图解TCP/IP>>,收获蛮多,记得上学时读stevens的<<TCP/IP具 ...
- php之 人员的权限管理
1.想好权限管理的作用? 2.有什么权限内容? 3.既然有权限管理那么就会有管理员? 4.登录后每个人员的界面会是不一样的? 一.想好这个权限是什么? 就做一个就像是vip的功能,普通用户和vip用户 ...
- sql server 字符串函数大全
平常会用到一些函数处理字符串,用的不算频繁,所以每次用到的时候就忘记了,这次在网上找了一篇文档,担心突然某一天这篇文章找不到了,然后就把文章的内容复制了一份: /* 1,ASCII返回字符表达式中最左 ...
- LINQ分页工具
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Co ...
- 【BZOJ2466】[中山市选2009]树 树形DP
[BZOJ2466][中山市选2009]树 Description 图论中的树为一个无环的无向图.给定一棵树,每个节点有一盏指示灯和一个按钮.如果节点的按扭被按了,那么该节点的灯会从熄灭变为点亮(当按 ...
- android菜鸟学习笔记23----ContentProvider(三)利用内置ContentProvider监听短信及查看联系人
要使用一个ContentProvider,必须要知道的是它所能匹配的Uri及其数据存储的表的结构. 首先想办法找到访问短信及联系人数据的ContentProvider能接受的Uri: 到github上 ...
- 类加载(一):static块 和 Class.forName
1. class Some { static{ System.out.println("1"); } public Some(){ System.out.println(" ...
- pg 和sql server 分别如何新建二进制数据库字段以及插入二进制数据的sql语句
PG create table demo ( id int, name bytea ); Insert into demo (id,name)values(256,pg_read_binary_fil ...
- Android Studio实现代码混淆
1,在build.grandle添加,其中规则写在proguard-rules.pro中,也可以自定义一个文件,将其代替,比如eclipse常用的 proguard-project.txt: bui ...
- dojo 官方翻译 dojo/json 版本1.10
官方地址:http://dojotoolkit.org/reference-guide/1.10/dojo/json.html#dojo-json require(["dojo/json&q ...