博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #459 (Div. 2) AB
阅读量:4613 次
发布时间:2019-06-09

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

A. Eleven
 

Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters.

Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested that the i-th letter of her name should be 'O' (uppercase) if i is a member of Fibonacci sequence, and 'o' (lowercase) otherwise. The letters in the name are numbered from 1 to n. Fibonacci sequence is the sequence f where

  • f1 = 1,
  • f2 = 1,
  • fn = fn - 2 + fn - 1 (n > 2).

As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name.

Input

The first and only line of input contains an integer n (1 ≤ n ≤ 1000).

Output

Print Eleven's new name on the first and only line of output.

Examples
input
8
output
OOOoOooO
input
15
output
OOOoOooOooooOoo

 是斐波拉契数就是‘O’否则就是‘o’

1 n = int(input()) 2  3 vis = [] 4 a ,b = 1, 1 5 for i in range(55): 6     vis.append(b) 7     a,b = b,a+b 8 s = "" 9 for i in range(n):10     if vis.count(i+1):11         s += 'O'12     else :13         s += 'o'14 print(s)

 

 

B. Radio Station
 

As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we'll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.

Each ip is of form "a.b.c.d" where abc and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.

Dustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him.

Input

The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000).

The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct.

The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, commandonly consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.

Output

Print m lines, the commands in the configuration file after Dustin did his task.

Examples
input
2 2 main 192.168.0.2 replica 192.168.0.1 block 192.168.0.1; proxy 192.168.0.2;
output
block 192.168.0.1; #replica proxy 192.168.0.2; #main
input
3 5 google 8.8.8.8 codeforces 212.193.33.27 server 138.197.64.57 redirect 138.197.64.57; block 8.8.8.8; cf 212.193.33.27; unblock 8.8.8.8; check 138.197.64.57;
output
redirect 138.197.64.57; #server block 8.8.8.8; #google cf 212.193.33.27; #codeforces unblock 8.8.8.8; #google check 138.197.64.57; #server

 有n台服务器,m条命令,求每个命令的名字指向的服务器ip在n台服务器中原来的名字是什么。

n,m = map(int,input().split())di = {}for i in range(n+m):    s,s1 = input().split()    if s1[-1] == ';':        s1 = s1[:-1]    if s1 in di:        print(s+' '+s1+'; #'+di[s1])    else:        di[s1] = s;

 

转载于:https://www.cnblogs.com/xingkongyihao/p/8387687.html

你可能感兴趣的文章
关于bootstrap Modal弹窗 滚动条的问题
查看>>
Django----------路由控制
查看>>
将数字转化为字符串的快捷方式
查看>>
java23种设计模式
查看>>
冲刺周期一--站立会议04
查看>>
支持IE6以上阴影效果纯CSS
查看>>
优化算法与特征缩放
查看>>
NOIP模板复习(4)区间操作之莫队算法,树状数组,线段树
查看>>
深入理解PHP中的引用和赋值
查看>>
58同城2018提前批前端笔试题总结
查看>>
compilation与编译
查看>>
useradd mfs -s /sbin/nologin -M
查看>>
mysql数据库:数据类型、存储引擎、约束、
查看>>
LeetCode-Find the Celebrity
查看>>
LeetCode-Longest Increasing Subsequence
查看>>
LeetCode-Reverse Bits
查看>>
zynq如何查看当前网速
查看>>
vue+element-ui实现表格checkbox单选
查看>>
linux公司常用基础命令必知必会
查看>>
网站优化
查看>>