[原]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最近发现在使用计算器计算高精度的大数加法时很不方便 ...
随机推荐
- 输入值/表单提交参数过滤有效防止sql注入的方法
输入值/表单提交参数过滤,防止sql注入或非法攻击的方法: 代码如下: /** * 过滤sql与php文件操作的关键字 * @param string $string * @return strin ...
- static全局变量与普通的全局变量有什么区别?static局部变量和普通局部变量有什么区别?static函数与普通函数有什么区别?
答案:全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量.全局变量本身就是静态存储方式,静态全局变量当然也是静态存储方式. 这两者在存储方式上并无不同.这两者的区别虽在于非静态全 ...
- 服务器端获取表单数据的编码解码问题(servlet)
首先需要明确指出的是,这里的服务器是指tomcat. 在页面没有明确指定编码的情况下,客户端通过input标签和字符串向服务器传递两个值param1和param2.如果直接使用request.getP ...
- Collective Mindsets (easy)(逻辑题)
Collective Mindsets (easy) Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- 右键打开cmd
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere]@="Open cmd ...
- Day 1 :成功完成注册
今天成功完成了cnblogs的注册,之后会在这里开业咯!记录下此刻时间
- 【oracle案例】ORA-01722
1.1. ORA-01722 日期:2014-06-05 14:09 环境:測试环境 [情景描写叙述] 在数据库的升级过程中,运行SQL> @?/rdbms/admin/catupgrd ...
- 使用 Node.js 对文本内容分词和关键词抽取
npm install nodejieba var nodejieba = require("nodejieba"); var result = nodejieba.cut(&qu ...
- STM32L0 HAL库 UART 串口读写功能
串口发送功能: uint8_t TxData[]= "01234abcde"; HAL_UART_Transmit(&huart2,TxData,,0xffff);//把T ...
- 查询某个字段为null并且某个字段不为null的数据
查询代码为null且ggid不为null的公司名 select name_of_invested_company from dwtz WHERE code is NULL and ggid is no ...