codeforces 213div(2) 365 A.Good Number 365 B.The Fibonacci Segment
#include <stdio.h>
#include <string.h>
bool vis[11];
int n, k;
bool judge(int x)
{
memset(vis, false, sizeof(vis));
if (x == 0)
vis[0] = true;
while (x)
{
vis[x%10] = true;
x /= 10;
}
for (int i = 0; i <= k; i++)
if (vis[i] == false)
return false;
return true;
}
int main()
{
int x;
while (scanf("%d %d", &n, &k) != EOF)
{
int ans = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d", &x);
if (judge(x))
ans++;
}
printf("%d\n", ans);
}
return 0;
}
B,求序列中最长满足斐波那契性质的序列长度。
#include <stdio.h> int a[100005]; int main()
{
int n;
while (scanf("%d", &n) != EOF)
{
int ans = 0;
int len = 0;
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
if (i > 2)
{
if (a[i] == a[i-1] + a[i-2])
{
len++;
if (len > ans)
ans = len;
}
else
{
len = 0;
}
}
}
if (n < 2)
printf("%d\n", n);
else
printf("%d\n", ans+2);
}
return 0;
}
codeforces 213div(2) 365 A.Good Number 365 B.The Fibonacci Segment的更多相关文章
- Codeforces Beta Round #51 B. Smallest number dfs
B. Smallest number Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/pro ...
- Office 365系列(三) -Office 365 Pro plus 安装
这一篇博客主要是说Office 365 Pro plus安装. 1. 当登陆到Office 365以后,点击右边链接“下载软件” 2. 安装最新Office 软件 3. 采用点对点安装,当安装成功以后 ...
- Codeforces 617 E. XOR and Favorite Number
题目链接:http://codeforces.com/problemset/problem/617/E 一看这种区间查询的题目,考虑一下莫队. 如何${O(1)}$的修改和查询呢? 令${f(i,j) ...
- codeforces 617E E. XOR and Favorite Number(莫队算法)
题目链接: E. XOR and Favorite Number time limit per test 4 seconds memory limit per test 256 megabytes i ...
- Codeforces Round #266 (Div. 2) C. Number of Ways
You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split ...
- 【第400篇题解纪念2016年10月28日】【28.10%】【codeforces 617E】XOR and Favorite Number
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces 617E:XOR and Favorite Number(莫队算法)
http://codeforces.com/problemset/problem/617/E 题意:给出n个数,q个询问区间,问这个区间里面有多少个区间[i,j]可以使得ai^ai+1^...^aj ...
- codeforces 617 E. XOR and Favorite Number(莫队算法)
题目链接:http://codeforces.com/problemset/problem/617/E 题目: 给你a1 a2 a3 ··· an 个数,m次询问:在[L, R] 里面又多少中 [l, ...
- Codeforces Round #651 (Div. 2) C. Number Game(数论)
题目链接:https://codeforces.com/contest/1370/problem/C 题意 给出一个正整数 $n$,Ashishgup 和 FastestFinger 依次选择执行以下 ...
随机推荐
- 微服务之服务注册与发现--Consul(转载)
http://blog.csdn.net/buxiaoxia/article/details/69788114 https://www.cnblogs.com/xiaohanlin/p/8016803 ...
- [python] 安装TensorFlow问题 解决Cannot uninstall 'wrapt'. It is a distutils installed project
cmd安装 pip install tensorflow 1.遇到了 ERROR: Cannot uninstall 'wrapt'. It is a distutils installed proj ...
- php如何定义数组常量
是这样吗?<?php define('BEST_PHPER',array('name'=>'巩文','address'=>'china')); My God,明确告诉你不可以:原因是 ...
- mysql的union和or
实践出真知! 使用union连接 select `id` from `表名` where 0=0 and active=1 and `fullname` like '王%' union select ...
- centos7安装hadoop完全分布式集群
groupadd test //新建test工作组 useradd -g test phpq //新建phpq用户并增加到test工作组 userdel 选项 用 ...
- re正则
#转义字符和原生字符 import re # # # 转义 # text = 'apple price is $299' # ret = re.search('\$\d+',text) # print ...
- 数字IC前后端设计中的时序收敛(三)--Hold违反的修复方法
本文转自:自己的微信公众号<数字集成电路设计及EDA教程>(二维码见博文底部) 里面主要讲解数字IC前端.后端.DFT.低功耗设计以及验证等相关知识,并且讲解了其中用到的各种EDA工具的教 ...
- dapper支持DataSet
在源代码中添加 /// <summary> /// describe:支持 DataSet /// </summary> /// <param name="cn ...
- python 3.7 新特性 - popitem
百度上大多文章说 popitem 随机删除字典的一个键值对 python 3.7 官方文档已经说了,popitem 删除字典最后一个添加进去的键值对
- 聊聊Java String.intern 背后你不知道的知识
Java的 String类有个有意思的public方法: public String intern() 返回标准表示的字符串对象.String类维护私有字符串池. 调用此方法时,如果字符串池已经包含等 ...