博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
BestCoder Round #28
阅读量:2440 次
发布时间:2019-05-10

本文共 2630 字,大约阅读时间需要 8 分钟。

1001

Missing number


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 748    Accepted Submission(s): 275


Problem Description
There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose.
 
Input
There is a number    
T shows there are
T test cases below. (
T≤10 )
For each test case , the first line contains a integers
n , which means the number of numbers the permutation has. In following a line , there are
n distinct postive integers.(
1≤n≤1,000 )
 
Output
For each case output two numbers , small number first.
 
Sample Input
233 4 511
 
Sample Output
1 22 3
 
题意:给你n个数,问哪两个数丢失。

解题思路:题意给的n个数是1~n+2之间的数,因此只需要将在1~n+2之间却不在给定的n个数的数找出来即可。

参考代码:

#include 
#include
#include
#include
#include
using namespace std;typedef long long ll;int main(){ int n,t,a; bool used[1003]; cin>>t; while (t--){ cin>>n; memset(used,false,sizeof(used)); for (int i=0;i
>a; used[a]=true; } int flag=0; for (int i=1;i<=n+2;i++){ if (used[i]==false){ flag++; if (flag==1) cout<
<<" "; if (flag==2) cout<<
1002

Fibonacci


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 996    Accepted Submission(s): 40


Problem Description
Following is the recursive definition of Fibonacci sequence:   
Fi=⎧⎩⎨01Fi−1+Fi−2i = 0i = 1i > 1
Now we need to check whether a number can be expressed as the product of numbers in the Fibonacci sequence.
 
Input
There is a number    
T shows there are
T test cases below. (
T≤100,000 )
For each test case , the first line contains a integers n , which means the number need to be checked.
0≤n≤1,000,000,000
 
Output
For each case output "Yes" or "No".
 
Sample Input
3417233
 
Sample Output
YesNoYes
 
题意:给出fib数列,问任意给定的一个n是否可以是fib数列中的若干fib数的积;

解题思路:首先用一个数组将fib数列保存下来,然后求出用一个数组将Fibonacci数组中属于n的因子的数保存,最后在递归搜索求解是否存在n是这些Fibonacci数组成的积;

参考代码:

#include 
#include
#include
#include
#include
#include
#include
using namespace std;int fib[100],a[100],i,k;bool work(int n,int step){ //递归搜索求解是否存在n是这些Fibonacci数组成的积 if (n==1) return true; for (int j=step;j
>t; while (t--){ cin>>n; if (n==0){ cout<<"Yes"<

转载地址:http://bfbqb.baihongyu.com/

你可能感兴趣的文章
如何解决JavaScript中的“不是函数”错误
查看>>
tcp协议_TCP协议
查看>>
c语言中双引号和单引号_C中的双引号与单引号
查看>>
opencv 图像黑暗_如何在黑暗模式下更改HTML图像URL
查看>>
sql中select 使用_SQL,如何使用SELECT
查看>>
udp协议_UDP协议
查看>>
反向代理为什么叫反向代理_什么是反向代理?
查看>>
js访问对象键值属性_我们可以通过哪些方式访问对象属性的值?
查看>>
如何在JavaScript中删除字符串的最后一个字符
查看>>
c语言检查字符函数_如何在C中检查字符值
查看>>
如何在JavaScript中删除字符串的第一个字符
查看>>
rcp扩展文本编辑器_我如何使用文本扩展来节省时间
查看>>
c语言中的i/o_C语言中的基本I / O概念
查看>>
c语言 函数 返回 字符串_如何从C函数返回字符串
查看>>
react 表单自动提交_我如何解决React登录表单状态和浏览器自动填充的问题
查看>>
macbook 黑暗模式_在黑暗模式下更改图标
查看>>
未定义符号错误_包裹,如何修复“ regeneratorRuntime未定义”错误
查看>>
JavaScript中的null和undefined有什么区别?
查看>>
safari无法退出_Safari,退出前警告
查看>>
如何使用Mac连接到Raspberry Pi
查看>>