Noj - 在线强化训练1
| 1445 | A | 求n个整数的和 | |
| 1564 | B | 判断一个数是否是完全数 | |
| 1011 | C | 判素数(Prime number) | |
| 1566 | D | 输入一组整数,找出最小值 | |
| 1200 | E | 判断三角形是否为直角三角形 | |
| 1508 | F | 袋子里有多少个球(一般情况) | |
| 1139 | G | 叙拉古猜想 | |
| 1135 | H | 阿姆斯特朗数(Armstrong number) | |
| 1031 | I | 求阶乘和(the sum of Factorial) | |
| 1402 | J | 数字根(Digital Roots) | |
| 1567 | K | 拆分数字并从低位到高位输出 | |
| 1565 | L | 十进制数转二进制从低位到高位输出 |
Problem A 求n个整数的和 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 先输入一个正整数n,再输入n个整数,求它们的和。 输入: 先输入一个正整数n,再输入n个正整数, 输出: 输出它们的和 输入样例: 输出样例:
Problem A 求n个整数的和
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
;
int temp;
; i<n; i++)
{
cin>>temp;
sum += temp;
}
cout<<sum<<endl;
}
;
}
代码A
Problem B 判断一个数是否是完全数 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 如果一个大于2的整数的不包含它自身的约数之和恰好等于它本身,则称其为完全数。如:=++,所以,6是个完全数。 Perfect number is defined as follows:the sum of it’s common divisor which does not includes it’s maximum equals itself. 输入: 输入一个大于2的整数n, 输出: 编程判断n是不是完全数,如果是输出“Yes”,否则输出“No”。 输入样例: 输出样例: Yes
Problem B 判断一个数是否是完全数
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
;
; i<n; i++)
{
)
sum += i;
}
if(sum == n)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
;
}
代码B
Problem C 判素数(Prime number) 时限:100ms 内存限制:10000K 总时限:1000ms 描述: 给出一个数n(<=n<=),判定它是否为素数。 素数:一个大于等于2的数,除了1和它本身,再没有其他的整数能将其整除的数叫素数。 Input a number n(<=n<=), judge if it is a prime number. 输入: 从标准输入输入一个整数。 Input a number n(<=n<=) 输出: 若给定数为素数,向标准输出输出“Yes”,否则,输出“No”。 If the number is a prime, output “Yes”. Otherwise, output “No”. 输入样例: 输出样例: Yes
Problem C 判素数(Prime number)
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
;
; i<=n/; i++)
{
)
{
flag = ;
break;
}
}
if(flag)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
;
}
代码C
Problem D 输入一组整数,找出最小值 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 先输入一个正整数n,然后输入n个整数,输出其最小值。 输入: 先输入一个正整数n,然后输入n个整数。 输出: 输出其最小值(最后输出一个回车)。 输入样例: 输出样例:
Problem D 输入一组整数,找出最小值
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
;
int temp;
; i<n; ++i)
{
cin>>temp;
if(temp <= min)
min = temp;
}
cout<<min<<endl;
}
;
}
代码D
Problem E 判断三角形是否为直角三角形 时限:100ms 内存限制:10000K 总时限:1000ms 描述: 给定平面直角坐标系中的三个点的坐标,判断是否能构成直角三角形。 输入: 三个点的坐标,数据都在-100000到100000之间。 输出: 一个整数,当可以构成直角三角形的时候输出1,否则输出0。 输入样例: 输出样例:
Problem E 判断三角形是否为直角三角形
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
];
; i<; i++)
{
cin>>p[i];
}
double a,b,c;
a = (p[]-p[])*(p[]-p[]) + (p[]-p[])*(p[]-p[]);
b = (p[]-p[])*(p[]-p[]) + (p[]-p[])*(p[]-p[]);
c = (p[]-p[])*(p[]-p[]) + (p[]-p[])*(p[]-p[]);
if(a+b==c || a+c==b || b+c == a)
cout<<<<endl;
else
cout<<<<endl;
;
}
代码E
Problem F 袋子里有多少个球(一般情况) 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 袋子里有若干个球的问题,聪明的佳佳很快就算出来了,但是他想写一个程序解决这个问题,并想把问题扩展到一般情况:每次拿出其中的一半再放回去一个球,一共这样做了n次,袋子里还有m个球。问原来袋子中有多少个球? 输入: 输入两个正整数n和m, 输出: 袋子里原来有多少个球 输入样例: 输出样例:
Problem F 袋子里有多少个球(一般情况)
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n, m;
cin>>n;
cin>>m;
; i<n; i++)
{
m = (m-) * ;
}
cout<<m<<endl;
;
}
代码F
Problem G 叙拉古猜想 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 叙拉古猜想又称科拉兹猜想、哈塞猜想、3n+1猜想、乌拉姆猜想或角谷猜想,是指对于每一个大于1的正整数,如果它是奇数,则将其乘3加1,如果它是偶数,则将除以2,如此循环,最终将得到1。 Syracuse conjecture also known conjecture the Ulam conjecture or angle Valley conjecture, means , and plus1, , and so on, will eventually give . 输入: 输入数据包含一个整数N(<N<=)。 Input a positive integer. 输出: 输出数据包含从这个整数到1的按照叙拉古猜想变换的序列,每行一个数字。 Output the sequence in accordance with the Syracuse guess, one per line figures. 输入样例: 输出样例:
Problem G 叙拉古猜想
#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int N;
while(cin>>N)
{
cout<<N<<endl;
)
{
== )
N /= ;
else
N = N* + ;
cout<<N<<endl;
}
}
}
代码G
Problem H 阿姆斯特朗数(Armstrong number) 时限:1000ms 内存限制:10000K 总时限:1000ms 描述: 阿姆斯特朗数又称水仙花数,是指一种三位数,其各个数字之立方和等于该数。 Armstrong number which is also called Daffodils number is a three-figure number,and the sum of the number of it’s respective positions equals itself. For example = ** + ** + ** 输入: 本题无输入 None 输出: 升序输出所有阿姆斯特朗数,每个数字占一行。 Output all Armstrong number in ascending order and every integer occupies a line only. 输入样例: 无None 输出样例: 无None
Problem H 阿姆斯特朗数(Armstrong number)
#include <iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int a,b,c;
; i<; i++)
{
a = i/;
b = (i-a*) / ;
c = i-a*-b*;
if(i == a*a*a + b*b*b + c*c*c)
cout<<i<<endl;
}
}
代码H
Problem I 求阶乘和(the sum of Factorial) 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 给你一个正整数n,请你求1到n的阶乘的和,并输出最后结果 如给你5 , 即计算 !+!+!+!+! Input a positive integer n,and calculate the sum of n!.For example,n and calculate the following formula: !+!+!+!+! 输入: 一个正整数n a positive integer n. 输出: 求得的阶乘和 The sum of n! 输入样例: 输出样例:
Problem I 求阶乘和(the sum of Factorial)
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
;
int temp;
; i<=n; i++)
{
temp = ;
; j<=i; j++)
temp *= j;
sum += temp;
}
cout<<sum<<endl;
}
}
代码I
Problem J 数字根(Digital Roots) 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 一个正整数的数字根是指该数字各位数字之和,如果和是一个个位数,那么这个数字就是它的数字根,如果和是个两位或多于两位的数字,那么就继续求和直到得到个位数。 例如:数字24,把2和4相加,得到6,那么6就是24的数字根;又比如数字39,把数字3和9相加,得到12,因为12时是两位数,所以继续把1和2相加,得到3,于是3就是39的数字根。 The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit. For example, consider the positive integer . Adding the and the yields a value of . Since . Now consider the positive integer . Adding the and the yields . Since and the yeilds , a single digit and also the digital root of . 输入: 输入一个正整数, input a positive integer, 输出: 输出它的数字根。 Output its digital root. 输入样例: 输出样例:
Problem J 数字根(Digital Roots)
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
int temp;
;
while(n)
{
temp = n%;
n /= ;
sum += temp;
}
)
cout<<sum<<endl;
else
{
int temp2,temp3;
)
{
temp2 = sum;
sum = ;
while(temp2)
{
temp3 = temp2%;
temp2 /= ;
sum += temp3;
}
}
cout<<sum<<endl;
}
}
}
代码J
Problem K 拆分数字并从低位到高位输出 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 输入一个正整数,将其各个位上的数字按从低位到高位的顺序单独输出,每个数字占一行。提示可用两种除法/和%,用于整数时第一种除法的结果是商的整数部分,第二种除法的结果是余数,例如:/=,%=) 输入: 一个正整数。 输出: 将其各个位上的数字按从低位到高位的顺序单独输出,每个数字占一行。 输入样例: 输出样例:
Problem K 拆分数字并从低位到高位输出
#include <iostream>
using namespace std;
void swap(int *p,int *p2);
int main()
{
int n;
];
while(cin>>n)
{
;
while(n)
{
num[i] = n % ;
n /= ;
i++;
}
; j<i; j++)
{
cout<<num[j]<<endl;
}
}
}
代码K
Problem L 十进制数转二进制从低位到高位输出 时限:1000ms 内存限制:10000K 总时限:3000ms 描述: 输入一个十进制数,把它转成二进制数后,从低位到高位输出。 输入: 一个十进制数n。 输出: 把n转化为二进制数以后,从地位到高位输出(每个数字占一行)。 输入样例: 输出样例:
Problem L 十进制数转二进制从低位到高位输出
#include <iostream>
using namespace std;
void swap(int *p,int *p2);
int main()
{
int n;
while(cin>>n)
{
];
;
while(n)
{
b[i] = n % ;
n /= ;
i++;
}
; j<i; j++)
{
cout<<b[j]<<endl;
}
}
}
代码L
Noj - 在线强化训练1的更多相关文章
- Noj - 在线强化训练3
状态 题号 竞赛题号 标题 1091 A 求解逆波兰表达式(Calculate the reverse Polish notation) 1017 B 数列 1323 C 穷举n位二进制数 ...
- Noj - 在线强化训练4
状态 题号 竞赛题号 标题 × 1092 A 童年的回忆——计算24 × 1145 B 求图像的周长 × 1144 C 农场灌溉问题 × 1202 D 数独游戏 × 1243 E 循环赛日程表 × 1 ...
- Noj - 在线强化训练2
状态 题号 竞赛题号 标题 1572 A 九鼎之尊(一) 1573 B 九鼎之尊(二) 1453 C 筛法(Sieve Method) 1134 D 亲密数(close numbers ...
- Hinton胶囊网络后最新研究:用“在线蒸馏”训练大规模分布式神经网络
Hinton胶囊网络后最新研究:用“在线蒸馏”训练大规模分布式神经网络 朱晓霞发表于目标检测和深度学习订阅 457 广告关闭 11.11 智慧上云 云服务器企业新用户优先购,享双11同等价格 立即抢购 ...
- Android:JNI强化训练
一.前言 Java本机接口(Java Native Interface (JNI))是本机编程接口,它是JDK的一部分,JNI它提供了若干的API,实现了和Java和其他通信(主要是C&C++ ...
- Python强化训练笔记(七)——使用deque队列以及将对象保存为文件
collections模块中的deque对象是一个队列,它有着正常队列的先进先出原则.我们可以利用这个对象来实现数据的保存功能. 例如,现有一个猜数字大小的游戏,系统开始会随机roll点一个0-100 ...
- Python强化训练笔记(六)——让字典保持有序性
python的字典是一个非常方便的数据结构,使用它我们可以轻易的根据姓名(键)来找到他的成绩,排名等(值),而不用去遍历整个数据集. 例如:{'Lee': [1, 100], 'Jane': [2, ...
- Python强化训练笔记(五)——找出多个字典中的公共键
在这个问题中,我们期望得到的结果是找到这三轮比赛中,每轮都进球的球员都有谁.下面用python来模拟一下,先生成一批数据: >>> from random import randin ...
- ACM: 强化训练-Beautiful People-最长递增子序列变形-DP
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard ...
随机推荐
- wireshark找(检测)不到(捕获)网卡的解决办法
1 前言 有时候打开wireshark,会提示找不到可用网卡,此时是因为NetGroup Packet Filter Driver 服务没有开启. 环境:笔记本 系统:Win10 网络:WIFI 2 ...
- php 汉字的首字母
<?php//php获取中文字符拼音首字母function getFirstCharter($str){ if(empty($str)) { return ''; } $fchar=ord($s ...
- Confluence 6 附件存储文件系统的分级
从 Confluence 3.0 开始,附件的存储方式有了重大的改变和升级.如果你是从 Confluence 2.10 及其早期版本升级上来的,请参考 Upgrading Confluence 页面中 ...
- Confluence 6 与其他应用整合
你可以使用 应用链接(Application Links)将 Confluence 与其他应用进行整合.应用链接允许你连接 Confluence 到其他的应用,例如 JIRA 软件或者 JIRA 服务 ...
- 巧用&&和|| 让逻辑代码更简洁,逼格看起来更高一点(玩笑脸)
通常当我们有一个需求 需要用到很多if else 进行条件筛选,例如: let level = 0; if(score > 12){ level = 4; } else if(score > ...
- AD9361寄存器配置顺序,循环模式,自收自发
:] cmd_data; :] index; begin case(index) 'h000,8'h00};//set spi -- 'h3df,8'h01};//set init -- 'h037, ...
- func_get_args函数
func_get_args ------获取一个函数的所有参数 function foo() { $numargs = func_num_args(); //参数数量 echo "参数个数是 ...
- 基于kali linux无线网络渗透测试
1.无线网络渗透测试目前主要有三种方式,分别是暴力破解PIN码,跑握手包,搭建伪热点三种方式,当然还存在其他的方式. 1.1暴力破解 路由器的PIN码由八位0-9的数字组成,PIN码由散步风组成,前四 ...
- oracle 备份脚本
本文是一个shell脚本.主要用于Oracle 数据库备份.默认情况下,在周一晚上进行全备.其他时间进行累积增量备份. 使用方法: 假如脚本保存名为: oracle_backup.sh 使用方法为 o ...
- NPOI操作Excel(一)--NPOI基础
用C#读取Excel的方法有很多中,由于近期工作需要,需要解析的Excel含有合并单元格以及背景色等特殊要求,故在网上查了一些关于读Excel的方法的优缺点,觉得NPOI能满足我的需要,所以搜索了一些 ...