nyoj_216_A problem is easy_201312051117
A problem is easy
- 描述
- 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 - 上传者
- 苗栋栋
-
#include <stdio.h>
#include <math.h> int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int i,j,t,n;
int num=;
scanf("%d",&n);
for(i=;i<=sqrt((double)n)+;i++)
{
if((n-i)%(i+)==)
if((n-i)/(i+)>=i)
num++;
}
printf("%d\n",num);
}
return ;
}优秀代码:
#include<cstring> #include<cstdio> #include<map> #include<string> #include<algorithm> #include<vector> #include<iostream> #include<cmath> using namespace std; #define CLR(arr,val) memset(arr,val,sizeof(arr)) int main() { int t,n,cnt=; //long long num; int num; scanf("%d",&t); while(t--) { // scanf("%lld",&num); scanf("%d",&num); int nn=(int)(sqrt(num+1.0)+0.5); num++; cnt=; for(int i=;i<=nn;i++) if(num%i==) cnt++; printf("%d\n",cnt); } }
简单数学题
nyoj_216_A problem is easy_201312051117的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
随机推荐
- vs2010打开vs2012项目
修改.sln文件的前两行 修改前: Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 修 ...
- 创建 /dev/video0 节点 (转载)
转自:http://blog.csdn.net/linuxmake/article/details/8208464 最近做摄像头驱动,发现没有 /dev/video0节点,经过查看发现是内核编译时没有 ...
- SpringBoot2.0整合SpringSecurity实现WEB JWT认证
相信很多做技术的朋友都做过前后端分离项目,项目分离后认证就靠JWT,费话不多说,直接上干活(写的不好还请多多见谅,大牛请绕行) 直接上代码,项目为Maven项目,结构如图: 包分类如下: com.ap ...
- Android框架式编程之Room
Room是Google官方出品的ORM(Object-relational mapping) 框架.当前我们也知道当前还有很多的ORM框架,例如GreenDao.OrmLite.Litepal等.目前 ...
- NS2学习笔记(四)
这几天学习NS2,虽然国内很多人使用,但系统的教材资料不多,只能一边看中文教材,一边看英文手册,知识点也是零零散散.过段时间等能将所有知识点串上,再总结总结.现只讲一些零碎的点记录一下. 添加新的协议 ...
- Coursera公开课-Machine_learing:编程作业
第二周编程作业:Linear Regression 分为单一变量和多变量,假想函数为:hθ(x)=θ0+θ1x1+θ2x2+θ3x3+⋯+θnxn.明显已经包含单一变量的情况,所以完成多变量可以一并解 ...
- Ubuntu 系统的常用快捷键
Ubuntu操作基本快捷键 ibus-setup :设置系统输入法 scp filename username@serverIp:/home/xxx/xxx/filename 回车输入该usern ...
- 简单的KKL诊断线~~~自己在家都可以制作obd诊断接口了 ~~
简单的KKL诊断线~~~自己在家都可以制作~~ 适合bmw 07年以前的车型,因为新的车型使用D-can作为诊断接口,所以不能再使用kkl诊断接口不过SB开头的宝马3系还是可以使用的 更多内容欢迎查看 ...
- mysql索引初认识
mysql> use mysql; Database changed mysql> show index from user; +-------+------------+-------- ...
- Windows开发小问题集
ON_BN_KILLFOCUS无效,因为需要BS_NOTIFY