神Lisy的智

神Lisy的智商

Lisy是个很聪明的人,他有一个智力值。 

和比他聪明的人(智力值大于Lisy的,这个真心不多)辩论一次智力值会+2。
和比他笨的人(智力值小于等于Lisy)辩论一次智力会+1。
然后每个人只能辩论一次。安排一个辩论顺序。使得辩论完后Lisy的智商最高。
Orz神Lisy。

Input

第一行为一个整数K,表示数据组数。

每组数据有两行:
  第一行包含两个正整数n和p,表示要和Lisy辩论的人数,以及Lisy的初始智力值。
  第二行包含n个正整数,表示这n个人的智力值。

Output

第一行包含一个正整数,表示Lisy最终智力值的最大值。

Sample Input

2
5 91
88 98 92 94 90
1 90
90

Sample Output

99
91
贪心的思想,将所有人的智商排序,使lisy每次与和他智商最接近且大于他的人辩论,一直到最后,剩下的没辩论过的即为+1的
code:
<span style="font-size:18px;">#include <iostream>
#include<algorithm>
using namespace std;

int main()
{
    int t,n,tem,a[1100],i;
    cin>>t;
    while(t--)
    {
        cin>>n>>tem;
        for(i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        int k=0;
        for(i=0;i<n;i++)
        {
            if(a[i]>tem)
            {
                tem+=2;
                k++;
            }
        }
           tem=tem+(n-k);
           cout<<tem<<endl;
    }
    return 0;
}</span>

化身


 
 

三国杀最近更新的武将中有一位叫“迷之仙人”——左慈的武将,他有两个技能:(1)化身——所有人都展示武将牌后,你随机获得两张未加入游戏的武将牌,选一张置于你面前并声明该武将的一项技能,你拥有该技能且同时将性别和势力属性变成与该武将相同直到该化身被替换。在你的每个回合开始时和结束后,你可以替换化身牌,你须为新的化身重新声明一项技能。(你不可声明限定技、觉醒技或主公技)。(2)新生——你每受到1点伤害,可获得一张新化身牌。游戏过程中化身牌是不需要展示的,其他人只能通过左慈声明的技能来推断他现在化身成了哪位武将,这项艰巨的任务就交给你了~~

Input

 

第一行为整数N(2≤N≤50),代表目前摸到的武将牌的数量(假设左慈是可以摸到这么多化身牌的);一个字符串代表当前声明的技能;

接下来N行,每行一个整数,代表武将的序号;一个整数M(1≤M≤5),代表该武将的技能数量;之后M个字符串(只包括小写字母),代表武将技能(不包括限定技、觉醒技和主公技),同时用空格隔开,字符串长度<10。

Output

 

输出当前声明的技能所属的武将序号   

Sample Input

2 aaa
1 2 aaa bbb
2 1 ccc

Sample Output

1
思路:
使用map 是字符与数字对应
code:
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    map<string, int> Ballon;
    string color, MaxColor,ss,s;
    int n, ord,t;
    cin>>n>>ss;
        Ballon.clear();
        while(n--){
            cin>>ord>>t;
            for(int i=0;i<t;i++)
            {
                cin>>s;
                Ballon[s]=ord;
            }
        }
        map<string, int>::iterator it;
       // max = 0;
        for(it=Ballon.begin(); it!=Ballon.end(); it++){
            if(it->first==ss){
cout<<it->second;
            }
        }
    return 0;
}

整数边直角三角形

我国是最早发现勾股定理的国家,《周髀算经》记载的古人商高关于勾股定理的应用距今已有三千多年的历史。事实上,古人对于勾股定理的研究主要是针对整数边直角三角形。整数边直角三角形是指两条直角边和斜边都为整数的直角三角形。关于整数边直角三角形有一个有趣的结论:以任何大于2的素数为直角边的整数边直角三角形唯一存在。现在就希望你帮忙找出给定素数作为一直角边的整数边直角三角形。

Input

 

第一行一个正整数T(T<=100),表示一共有多少组数据,接下来T行,每一组数据一行,含有一个大于2的素数P(2<P<=107)。

Output

 

对于每组数据,输出一行为给定素数作为一直角边的整数边直角三角形三边长,按从小到大的顺序输出,以空格隔开。

Sample Input

2
3
5

Sample Output

3 4 5
5 12 13
以一素数为直角边的指教三角形唯一存在,其余两边为相邻自然数,且两数之和为该素数的平方 PS :long long
类型,不然会WA!!!
code:
#include<iostream>
using namespace std;
int main()
{
    long long n,m,i,ans,ans2;
    cin>>n;
    while(n--)
    {
        cin>>m;
        ans=(m*m-1)/2;
        ans2=ans+1;
        cout<<m<<" "<<ans<<" "<<ans2<<endl;
    }
    return 0;
}
<h2 class="pagetitle" style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 31.5px; text-align: center;">找规律问题</h2>string 类处理较为容易:
<h2 class="pagetitle" style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 31.5px; text-align: center;">校队的聚餐</h2><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">在辛苦了一个暑假+半个学期之后,神棍的2012赛季终于结束了。大牛决定好好地请大家吃一顿大餐!</p><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">学校周边有2<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">n</span>家餐馆(将它们编号为0,1,2…2<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">n</span>-1),校队有M名队员。现在大家在讨论去哪家餐馆吃饭,一开始大牛给出了第一种决定方案——由大牛决定去哪家餐馆。由于在大牛眼中食物只分为喜欢吃和爱吃两类,因此大牛会从2<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">n</span>家餐馆中等概率地随机选择一家。</p><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">但大家感觉这一方案无法体现出校队民主的优秀特点,于是提出了方案二——M名队员每人选择一家餐馆,取餐馆编号的平均数作为最后的决定。由于在大家眼中只要大牛请客去哪都行,因此所有人都会从2<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">n</span>家餐馆中等概率地随机选择一家。</p><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">但很快大家发现第二种方案并不能保证得出的决定是整数,于是提出了方案三——M名队员每人选择一家餐馆,将每人所选的编号取异或后作为最后的决定。由于跟方案二相同的原因,因此所有人都会从2<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">n</span>家餐馆中等概率地随机选择一家。</p><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">temperlsyer作为“随便”餐馆的忠实顾客,对最终结果完全不关心。他想知道的是,对于方案一、方案二、方案三,最终结果的期望分别是多少。</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Input</h3><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">输入只有两个整数N和M(0≤N≤30,0<M≤10<span style="overflow-wrap: break-word; position: relative; font-size: 12px; line-height: 0; vertical-align: baseline; top: -0.5em;">9</span>)。</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Output</h3><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">输出有三行,每行为一个小数,依次表示案一、方案二、方案三中最终结果的期望。相对或绝对误差在0.0001内均算正确。</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Sample Input</h3><pre class="content-wrapper" style="overflow-wrap: break-word; padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0px; margin-bottom: 10px; line-height: 20px; word-break: break-all; word-wrap: break-word; white-space: pre-wrap; background-color: rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.14902);">1 1

Sample Output

0.50
0.50
0.50
code:
#include <stdio.h>
#include <math.h>
int main()
{
    int N, M;
    while (~scanf("%d%d", &N, &M))
    {
        double s = (pow(2, N) - 1.0) / 2.0;
        printf("%.2lf\n%.2lf\n%.2lf\n", s, s, s);
    }
    return 0;
}
不要问我为什么,我没脑子!!!

<h2 class="pagetitle" style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 31.5px; text-align: center;"> Soft Kitty</h2><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">laimao很喜欢这首“BigBang”里的“Soft Kitty”,这首歌的歌词很简单只有6句,"soft kitty, warm kitty, little ball of fur,happy kitty, sleepy kitty, purr purr purr.",她总是唱着玩儿。现在她无聊了决定换一个玩法,你来说出一个数字n,她来唱出第n(1 ≤ n ≤ 10^9)句歌词。注意了她的唱法是,第i次唱这首歌时,每句歌词重复2^(i-1)次。就是像这样,“soft kitty, warm kitty, little ball of fur, happy kitty, sleepy kitty, purr purr purr, soft kitty, soft kitty, warm kitty, warm kitty, little ball of fur, little ball of fur,……”你能帮助她输出第n句歌词么(不包括标点)?</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Input</h3><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">多组数据,第一行是一个整数K(0<K<=100),表示数据组数。接下来K行,每行一个数字n,表示你需要输出第n句歌词。</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Output</h3><div class="content-wrapper well" style="overflow-wrap: break-word; min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: rgb(245, 245, 245); border: 1px solid rgb(227, 227, 227); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; -webkit-box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 1px 1px inset; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px;"><p style="overflow-wrap: break-word; margin-top: 0px; margin-bottom: 10px;">输出对应歌词</p><div style="overflow-wrap: break-word; clear: both;"></div></div><h3 style="overflow-wrap: break-word; margin: 10px 0px; font-family: Helvetica, sans-serif; line-height: 40px; color: rgb(49, 126, 172); text-rendering: optimizelegibility; font-size: 24.5px;">Sample Input</h3><pre class="content-wrapper" style="overflow-wrap: break-word; padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(51, 51, 51); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; margin-top: 0px; margin-bottom: 10px; line-height: 20px; word-break: break-all; word-wrap: break-word; white-space: pre-wrap; background-color: rgb(245, 245, 245); border: 1px solid rgba(0, 0, 0, 0.14902);">8
1
2
3
4
5
6
7
8

Sample Output

soft kitty
warm kitty
little ball of fur
happy kitty
sleepy kitty
purr purr purr
soft kitty
soft kitty
这很让我伤心,心疼了!
 
code:<pre name="code" class="cpp">#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

string str[] = {"soft kitty", "warm kitty", "little ball of fur", "happy kitty", "sleepy kitty", "purr purr purr"};

int main() {
    int K, n;
    cin >> K;
    while(K--) {
        cin >> n;

        if(n <= 6) {
            cout << str[n - 1] << endl;
            continue;
        }
        int rep = 1;
        while(n > rep * 6) {
            n -= rep * 6;
            rep *= 2;
        }
        int p = (n - 1) / rep;
        cout << str[p] << endl;
    }
    return 0;
}

 




                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值