An easy problem
Description
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 ?
Input
Output
Sample Input
2
1
3
Sample Output
0
1
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long n;
scanf("%I64d",&n);
n++;
int ans=;
long long m=sqrt(n);
for(long long i=;i<=m;i++)
{
if(n%i==) ans++;
}
printf("%d\n",ans);
}
}
n=i*j+i+j
==>n+1=(i+1)*(j+1)
An easy problem的更多相关文章
- UVA-11991 Easy Problem from Rujia Liu?
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...
- UVa 11991:Easy Problem from Rujia Liu?(STL练习,map+vector)
Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...
- POJ 2826 An Easy Problem?!
An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7837 Accepted: 1145 ...
- hdu 5475 An easy problem(暴力 || 线段树区间单点更新)
http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...
- 【暑假】[实用数据结构]UVa11991 Easy Problem from Rujia Liu?
UVa11991 Easy Problem from Rujia Liu? 思路: 构造数组data,使满足data[v][k]为第k个v的下标.因为不是每一个整数都会出现因此用到map,又因为每 ...
- HDU 5475 An easy problem 线段树
An easy problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...
- UVA 11991 Easy Problem from Rujia Liu?(vector map)
Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...
- 数据结构(主席树):HDU 4729 An Easy Problem for Elfness
An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65535/65535 K (J ...
- HDOJ(HDU) 2132 An easy problem
Problem Description We once did a lot of recursional problem . I think some of them is easy for you ...
随机推荐
- 【转】TextView长按复制实现方法小结
有这么一个需求,用户在浏览文本信息时希望长按信息就能弹出复制的选项方便保存或者在别的页面使用这些信息.类似的, 就像长按WebView或者EditText的内容就自动弹出复制选项. 这里面主要是2个特 ...
- algorithm 中的常用函数
非修改性序列操作(12个) 循环 对序列中的每个元素执行某操作 for_each() 查找 在序列中找出某个值的第一次出现的位置 fin ...
- KV6.60 SP1
组态王6.60 SP1全新发布! 组态王6.60 SP1对过去几年6系列中已解决过的故障进行了合并,包括各主线分支.各OEM版本中的故障总计122个,覆盖运行系统.开发系统.历史趋势曲线控件.报表.A ...
- windows系统下ftp上传下载和一些常用命令
先假设一个ftp地址 用户名 密码 FTP Server: home4u.at.china.com User: yepanghuang Password: abc123 打开windows的开始菜单, ...
- 【python】入门学习(七)
设置字符串格式: format % values >>> x =/ >>> print(x) 0.012345679012345678 >>> p ...
- python学习 登陆验证
#!/usr/bin/env python #-*- coding=utf-8 -*- #----------------导入模块------------------------------ impo ...
- supersr--class_copyIvarList和class_copyPropertyList的区别
class_copyPropertyList返回的仅仅是对象类的属性(@property申明的属性), 而class_copyIvarList返回类的所有属性和变量(包括在@interface大括号中 ...
- 25个增强iOS应用程序性能的提示和技巧(初级篇)
25个增强iOS应用程序性能的提示和技巧(初级篇) 标签: ios内存管理性能优化 2013-12-13 10:53 916人阅读 评论(0) 收藏 举报 分类: IPhone开发高级系列(34) ...
- mysql my.cnf配置文件详解
本配置文件针对Dell R710,双至强E5620.16G内存的硬件配置.CentOS 5.6 64位系统,MySQL 5.5.x 稳定版.适用于日IP 50-100w,PV 100-300w的站点, ...
- Mysql复制之路由
在主从复制读写分离的思路下,要想使所有写都到MasterServer,所有读都路由到Slave Server;就需要使用一些路由策略. 可以使用MysqlProxy[Mysql代理],据说MysqlP ...