A problem is easy(南阳oj216)(数学变型)
来源:互联网 发布:匿名举报网络诈骗 编辑:程序博客网 时间:2024/06/05 12:48
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
- 样例输入
213
- 样例输出
01
关键就是数学变型。
/*x+y+xy=n ==> x+y+xy+1=(x+1)(y+1)=n+1;因为y>=x,所以(x+1)(x+1)<=(x+1)(y+1)=n+1;即:(x+1)(x+1)<=n+1; */#include<stdio.h>int main(){int i,n,test,ans;scanf("%d",&test);while(test--){scanf("%d",&n);ans=0;for(i=1;(i+1)*(i+1)<=n+1;i++){if((n+1)%(i+1)==0) { ans++;}}printf("%d\n",ans);}}
0 0
- A problem is easy(南阳oj216)(数学变型)
- NYOJ:A problem is easy(数学)
- 南阳216 A problem is easy
- 南阳题目216-A problem is easy
- NYOJ216--A problem is easy【数学】
- 南阳理工ACM 题目216 A problem is easy
- NYOJ A problem is easy(水题)
- A problem is easy
- A problem is easy
- A problem is easy
- A problem is easy
- A problem is easy
- A problem is easy
- A problem is easy
- A problem is easy
- NYOJ - A problem is easy
- NYOJ - A problem is easy
- acm-A problem is easy
- 设置父视图的透明度不影响子视图的透明度
- QT 添加托盘菜单
- oracle错误消息字符串和表里字符串字段(分别)乱码的原因(NLS)
- Eclipses中嵌入API文档
- 揭秘低调的Oculus Touch,以及它背后的技术大牛
- A problem is easy(南阳oj216)(数学变型)
- 验证正则表达式
- Unable to add window -- token android.os.BinderProxy@xxx is not valid; is your activity running
- VS2010链接错误:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- HOOK过程学习摘记
- SharedPreferences的基本使用方法
- Java设计模式_结构型_享元模式_实现单元的共享
- Appium-bootstrap的调试方法
- Big Omicron and Big Omega and Big Theta