NYOJ题目216 A problem is easy

//AC  心得:思考题目要求,寻找好合适的条件。

#include<stdio.h>
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n,i;
int a=0;
scanf("%d",&n);
for(i=1;(i+1)*(i+1)<=n+1;i++)//数学平方数理想化
{
if((n+1)%(i+1)==0)//i*j+i+j =N 经过观察,可以变形为i*j+i+j+1=N+1,也就是说,可以进一步变形为(i+1)*(j+1)=N+1;
a=a+1;//由于要满足i<=j;
}
printf("%d\n",a);
}
return 0;
}

时间: 2024-11-05 13:39:19

NYOJ题目216 A problem is easy的相关文章

NYOJ 216 A problem is easy【数学题】

化简一下即可 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..

NYOJ 179 LK&#39;s problem (排序模拟)

链接:click here~~ 题意: 描述 LK has a question.Coule you help her? It is the beginning of the day at a bank, and a crowd  of clients is already waiting for the entrance door to  open. Once the bank opens, no more clients arrive, and  tellerCount tellers be

NYOJ:题目524 A-B Problem

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=860 My思路: 先用两个字符串储存这两个实数,然后再用另外两个字符串储存去掉符号和前后多余的0后的新"实数",最后只需要比较两个化简后的新字符就ok了. My代码实现: 1 #include<iostream> 2 using namespace std; 3 string simplify(string s) { //去字符串s的正负号和首尾多余的0 4 str

NYOJ 题目477 A+B Problem III

题目描述: 求A+B是否与C相等. 输入 T组测试数据.每组数据中有三个实数A,B,C(-10000.0<=A,B<=10000.0,-20000.0<=C<=20000.0)数据保证小数点后不超过4位. 输出 如果相等则输出Yes不相等则输出No 样例输入 3 -11.1 +11.1 0 11 -11.25 -0.25 1 2 +4 样例输出 Yes Yes No #include<stdio.h>int main(){ int N; scanf("%d&q

nyoj 513 A+B Problem IV 【Java大数】

这道题有点小坑.. 特殊数据 输入 0.0 0.0 输出 0 代码: import java.util.Scanner; import java.math.*; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); BigDecimal a, b, temp; temp = new BigDecimal("0.0"); while(cin.hasN

nyoj 803 A/B Problem 【Java大数】

 先用字符串将字符串接收,然后在用BigInteger就好了 代码: import java.util.Scanner; import java.math.*; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); while(cin.hasNextBigInteger()){ BigInteger aa, bb; //a = cin.nextBigDeci

NYOJ题目57 6174问题

----------------------------------------------------- 感觉这个OJ题目难度划分很不合理,这道理明明很简单却给了2的难度,而之前难度为0的水题有好多难死个人没做出来让我暗暗觉得自己脑子里都是屎... 把题目描述翻译成人话的意思就是多少次以后这个序列会出现,想明白这一点就比较简单了. AC代码: 1 import java.util.Arrays; 2 import java.util.Scanner; 3 4 public class Main

《算法概论》第八章的一些课后题目 关于NP-Complete Problem

8.3 STINGY SAT STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an assignment exists. Prove that STINGY SAT is N

NYOJ题目1049自增自减

--------------------------------- 简单的字符判断. AC代码: 1 import java.util.Scanner; 2 3 public class Main { 4 5 public static void main(String[] args) { 6 7 Scanner sc=new Scanner(System.in); 8 9 int times=Integer.parseInt(sc.nextLine()); 10 while(times-->0