nyoj 216-A problem is easy ((i + 1) * (j + 1) = N + 1)
216-A problem is easy
内存限制:64MB
时间限制:1000ms
特判: No
通过数:13
提交数:60
难度:3
题目描述:

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
C/C++ AC:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <climits> using namespace std; int main()
{
long long T, a, b;
cin >>T;
while (T --)
{
scanf("%lld", &a);
b = sqrt(a + );
long long cnt = ;
for (int i = ; i <= b; ++ i)
{
if ((a + ) % i == )
++ cnt;
}
printf("%lld\n", cnt);
}
}
nyoj 216-A problem is easy ((i + 1) * (j + 1) = N + 1)的更多相关文章
- ACM A problem is easy
A problem is easy 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 When Teddy was a child , he was always th ...
- [原]NYOJ-216-A problem is easy
大学生程序代写 /*A problem is easy 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 When Teddy was a child , he was a ...
- 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最近发现在使用计算器计算高精度的大数加法时很不方便 ...
- nyoj 477-A+B Problem III (fabs() <= 0.00001)
477-A+B Problem III 内存限制:64MB 时间限制:1000ms 特判: No 通过数:18 提交数:34 难度:1 题目描述: 求A+B是否与C相等. 输入描述: T组测试数据. ...
随机推荐
- 我要学并发-Java内存模型到底是什么
内存模型 在计算机CPU,内存,IO三者之间速度差异,为了提高系统性能,对这三者速度进行平衡. CPU 增加了缓存,以均衡与内存的速度差异: 操作系统增加了进程.线程,以分时复用 CPU,进而均衡 C ...
- .gitignore实现忽略提交
- Java Web项目中使用Freemarker生成Word文档遇到的问题
这段时间项目中使用了freemarker生成word文档.在项目中遇到了几个问题,在这里记录一下.首先就是关于遍历遇到的坑.整行整行的遍历是很简单的,只需要在整行的<w:tr></w ...
- 面试官,不要再问我“Java虚拟机类加载机制”了
关于Java虚拟机类加载机制往往有两方面的面试题:根据程序判断输出结果和讲讲虚拟机类加载机制的流程.其实这两类题本质上都是考察面试者对Java虚拟机类加载机制的了解. 面试题试水 现在有这样一道判断程 ...
- 神奇的 SQL 之团结的力量 → JOIN
前言 开心一刻 闺蜜家暴富,买了一栋大别野,喊我去吃饭,菜挺丰盛的,筷子有些不给力,银筷子,好重,我说换个竹子的,闺蜜说,这种银筷子我家总共才五双,只有贵宾才能用~我咬着牙享受着贵宾待遇,终于,在 ...
- 百万年薪python之路 -- 推导式
2.1列表推导式 首先我们先看一下这样的代码,给出一个列表,通过循环,想列表中添加1~10: li = [] for i in range(1,11): li.append(i) print(li) ...
- 从零开始把项目发布到maven仓库中心
sonatype准备操作 注册账号 https://issues.sonatype.org 1. 密码符号规范,并且工记住 新建项目 1. group id 如果你有com域名的所有权可以直接使用,如 ...
- Kafka常用操作备忘
启动nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &nohup ./bin/kafka-server-st ...
- 追查Could not get a databaseId from dataSource
Mybatis 创建连接池的时候报错: ERROR 2017-03-15 00:44:50,333 commons.JakartaCommonsLoggingImpl:38 Could not get ...
- Amazon S3数据存储
从官网下载aws 的unity插件,并做了简单修改(主要用修改PostObject),问题: (一)获取Pool ID 通过服务-Cognito-管理/新建用户池,可以新建或者获取Pool ID (二 ...