Codeforces 918A Eleven 918B Radio Station

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

哎,CF日常掉分

题意

题解

#include<iostream>
using namespace std;
int main()
{
    int a[1005];
    a[1]=a[2]=1;
    for(int i=3;i<1005;i++)
        a[i]=a[i-1]+a[i-2];
    int cnt=2;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i==a[cnt])
        {
            cnt++;
            cout<<"O";
        }
        else
            cout<<"o";
    }
    cout<<endl;
    return 0;
}

Radio Station
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
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 a, b, c 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, command only 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

题意

题解

用map很好做。。

#include<iostream>
#include<set>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        map<string,string> ss;
        string name,ip;
        for(int i=0;i<n;i++)
        {
            cin>>name>>ip;
            ss[ip]=name;
        }
        for(int i=0;i<m;i++)
        {
            cin>>name>>ip;
            ip=ip.substr(0,ip.length()-1);
            string tmp=ss[ip];
            cout<<name<<' '<<ip<<"; #"<<tmp<<endl;
        }
    }
    return 0;
}

原文地址:https://www.cnblogs.com/orion7/p/8387666.html

时间: 2024-10-10 08:53:05

Codeforces 918A Eleven 918B Radio Station的相关文章

Notifications:关于MVC模型中的&#39;radio station&#39;

转载请注明来源,谢谢——by Guava Notification 既iOS中的“通知”(广播站)机制可以用来监听系统.模型的变化. 接收端: 通过 [NSNotificationCenter defaultCenter] 获得一个共享实例,就用这个对象来接收广播. 收听广播的方法是,向对象发送消息: - (void)addObserver:(id)observer // you (the object to get notified) 收听广播的对象,对一般的controller来说是self

【Codeforces Round #459 (Div. 2) B】 Radio Station

[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace std; int n,m; map<string,string> dic; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_

浙南联合训练赛20180214

这场比赛题目还行,但是被一道数学题卡了 A - Supermarket CodeForces - 919A We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that

Codeforces Round #459 (Div. 2) AB

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 u

cf723c Polycarp at the Radio

Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to m, but he d

Hijacking FM Radio with a Raspberry Pi &amp; Wire

转载:https://null-byte.wonderhowto.com/how-to/hack-radio-frequencies-hijacking-fm-radio-with-raspberry-pi-wire-0177007/ In our first part on software-defined radio and signals intelligence, we learned how to set up a radio listening station to find and

Codeforces Round #375 (Div. 2) C

Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to

iOS 开源项目

iOS 开源项目 在 Github 上 Star 太多了,有时候很难找到自己想要的开源库,所以在此记录下来.便于自己开发使用,也顺便分享给大家. 动画 awesome-ios-animation收集了iOS平台下比较主流炫酷的几款动画框架 RCTRefreshControlqq的下拉刷新 TBIconTransitionKiticon 的点击动画过渡效果 PullToBounce类似百度外卖的下拉刷新动画 LiquidFloatingActionButton可定制水滴型浮动动态按钮组件及演示 C

Github 上的 iOS 开源项目

在 Github 上 Star 太多了,有时候很难找到自己想要的开源库,所以在此记录下来.便于自己开发使用,也顺便分享给大家. 动画 awesome-ios-animation收集了iOS平台下比较主流炫酷的几款动画框架 RCTRefreshControlqq的下拉刷新 TBIconTransitionKiticon 的点击动画过渡效果 PullToBounce类似百度外卖的下拉刷新动画 LiquidFloatingActionButton可定制水滴型浮动动态按钮组件及演示 CardAnimat