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 ...
随机推荐
- 苹果树(线段树+Dfs序)
1228 苹果树 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在卡卡的房子外面,有一棵苹果树.每年的春天,树上总 ...
- akka设计模式系列(Actor模型)
谈到Akka就必须介绍Actor并发模型,而谈到Actor就必须看一篇叫做<A Universal Modular Actor Formalism for Artificial Intellig ...
- Vue使用html2canvas将页面转化为图片
需求是微信端将页面截屏之后保存到本地,使用了html2canvas插件 先引入插件 npm install --save html2canvas 之后在你所需要使用的页面引入 import html2 ...
- Python3安装Scrapy
Microsoft Visual C++ Build Tools 最近项目在写爬虫,项目经理给了个Python Scrapy的爬虫项目,要求使用Java实现相关功能.于是乎在本地先后安装了Pytho ...
- Linux命令(004) -- watch
对Linux系统的操作过程中,经常会遇到重复执行同一命令,以观察其结果变化的情况.惯用的方法是:上下键加回车,或是Ctr+p然后回车.今天我们来了解一下watch命令,它可以帮助我们周期性的执行一个命 ...
- Mysql中timestamp用法详解
前言:时间戳(timestamp),一个能表示一份数据在某个特定时间之前已经存在的. 完整的. 可验证的数据,通常是一个字符序列,唯一地标识某一刻的时间.使用数字签名技术产生的数据, 签名的对象包括了 ...
- [转]linux sudo 命令
转自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/11/11/2245341.html “Sudo”是Unix/Linux平台上的一个 ...
- Js打开QQ聊天对话窗口
function openQQ() { var qq = $(this).attr('data-qq');//获取qq号 window.open('http://wpa.qq.com/msgrd?v= ...
- [转]Wote用python语言写的imgHash.py
#!/usr/bin/python import glob import os import sys from PIL import Image EXTS = 'jpg', 'jpeg', 'JPG' ...
- (转)Spring AOP的底层实现技术
AOP概述 软件的编程语言最终的目的就是用更自然更灵活的方式模拟世界,从原始机器语言到过程语言再到面向对象的语言,我们看到编程语言在一步步用更自然.更强大的方式描述软件.AOP是软件开发思想的一个飞跃 ...