Soft Kitty

Time Limit: 1000ms
Memory Limit: 65536KB

64-bit integer IO format: %lld      Java class name: Main

Type:

None

 

None
 
Graph Theory
 
    2-SAT
 
    Articulation/Bridge/Biconnected Component
 
    Cycles/Topological Sorting/Strongly Connected Component
 
    Shortest Path
 
        Bellman Ford
 
        Dijkstra/Floyd Warshall
 
    Euler Trail/Circuit
 
    Heavy-Light Decomposition
 
    Minimum Spanning Tree
 
    Stable Marriage Problem
 
    Trees
 
    Directed Minimum Spanning Tree
 
    Flow/Matching
 
        Graph Matching
 
            Bipartite Matching
 
            Hopcroft–Karp Bipartite Matching
 
            Weighted Bipartite Matching/Hungarian Algorithm
 
        Flow
 
            Max Flow/Min Cut
 
            Min Cost Max Flow
 
DFS-like
 
    Backtracking with Pruning/Branch and Bound
 
    Basic Recursion
 
    IDA* Search
 
    Parsing/Grammar
 
    Breadth First Search/Depth First Search
 
    Advanced Search Techniques
 
        Binary Search/Bisection
 
        Ternary Search
 
Geometry
 
    Basic Geometry
 
    Computational Geometry
 
    Convex Hull
 
    Pick's Theorem
 
Game Theory
 
    Green Hackenbush/Colon Principle/Fusion Principle
 
    Nim
 
    Sprague-Grundy Number
 
Matrix
 
    Gaussian Elimination
 
    Matrix Exponentiation
 
Data Structures
 
    Basic Data Structures
 
    Binary Indexed Tree
 
    Binary Search Tree
 
    Hashing
 
    Orthogonal Range Search
 
    Range Minimum Query/Lowest Common Ancestor
 
    Segment Tree/Interval Tree
 
    Trie Tree
 
    Sorting
 
    Disjoint Set
 
String
 
    Aho Corasick
 
    Knuth-Morris-Pratt
 
    Suffix Array/Suffix Tree
 
Math
 
    Basic Math
 
    Big Integer Arithmetic
 
    Number Theory
 
        Chinese Remainder Theorem
 
        Extended Euclid
 
        Inclusion/Exclusion
 
        Modular Arithmetic
 
    Combinatorics
 
        Group Theory/Burnside's lemma
 
        Counting
 
    Probability/Expected Value
 
Others
 
    Tricky
 
    Hardest
 
    Unusual
 
    Brute Force
 
    Implementation
 
    Constructive Algorithms
 
    Two Pointer
 
    Bitmask
 
    Beginner
 
    Discrete Logarithm/Shank's Baby-step Giant-step Algorithm
 
    Greedy
 
    Divide and Conquer
 
Dynamic Programming
                  Tag it!

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句歌词么(不包括标点)?

 

Input

多组数据,第一行是一个整数K(0<K<=100),表示数据组数。接下来K行,每行一个数字n,表示你需要输出第n句歌词。

 

Output

输出对应歌词

 

Sample Input

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 错误点分析:前缀和计算时出错,数据范围没有考虑好,要用longlong用了int 解题思路:用前缀和的下标来映射唱n首歌。
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
long long f[50];
long long suf[50];
string ss[10];
void work(){ ss[0]="soft kitty";
ss[1]="warm kitty";
ss[2]="little ball of fur";
ss[3]="happy kitty";
ss[4]="sleepy kitty";
ss[5]="purr purr purr";
f[0]=0;
suf[0]=0;
f[1]=6;
suf[1]=6;
for(int i=2;i<50;i++){ f[i]=f[i-1]*2;
suf[i]=suf[i-1]+f[i];
}
}
void solve(long long m){ int i;
for(i=1;i<50;i++){ if(suf[i]>=m){ break;
}
}
m-=suf[i-1];
long long ti=(long long)pow(2,i-1);
if(m%ti==0){ cout<<ss[m/ti-1]<<endl;
}else{ cout<<ss[m/ti]<<endl;
}
}
int main(){ int K;
work();
scanf("%d",&K);
while(K--){ long long n;
scanf("%lld",&n);
solve(n);
}
return 0;
}

  

 

BNU27937——Soft Kitty——————【扩展前缀和】的更多相关文章

  1. es6学习笔记--字符串&数值&数组&函数&对象的扩展

    这几天抽空学习了es6语法,关于字符串,数值,数组,函数以及对象的扩展,看到es6标准入门这本书,里面讲的扩展特别多,我认为有几部分在项目上用不到,就挑有用的当笔记学习了. 字符串的扩展 str.in ...

  2. 树(二)——二叉树

    目录 本章主要讲解内容为: 树的非递归遍历算法,两种版本 树的扩展前缀以及前缀中缀构建方法 源码 btree.cpp btree.h 基础知识 一.定义 二叉树的递归定义:二叉树是每个结点最多含有两棵 ...

  3. ios/mac/COCOA系列 -- UIALertVIew 学习笔记

    最近在学习ios开发,学习的书籍<ios7 Pragramming cookbook>,做笔记的目的以后方便查看.笔记形式是小例子,将书上的例子书写完整. UIAlertViewClass ...

  4. 综述-如何克服HTML5的“性工能”障碍

    http://ask.dcloud.net.cn/docs HTML5自出现以来,几经风雨,虽看似很有前途,但实际使用问题太多,DCloud为此踩了无数坑.但我们从未放弃,我们加入了W3C,发起了 H ...

  5. webpack3_脚手架

    webpack    记得 --save-dev 装入开发依赖 更新迭代快,需要有根据报错解决问题的能力,来融会贯通这个工具 这里的是 webpack3,其实已经到了 webpack4 了 采用了 w ...

  6. bsdiff差分算法

    bsdiff的基本原理 bsdiff是由Conlin Percival开源的一个优秀的差分算法,而且是跨平台的.在Android系统中所使用的imgdiff本质上就是bsdiff. bsdiff的依据 ...

  7. Apache Ignite上的TensorFlow

    任何深度学习都是从数据开始的,这是关键点.没有数据,就无法训练模型,也无法评估模型质量,更无法做出预测,因此,数据源非常重要.在做研究.构建新的神经网络架构.以及做实验时,会习惯于使用最简单的本地数据 ...

  8. tomcat启动(三)Catalina分析-load方法分析

    load()方法按从上到下顺序分析(主要分析本人所没学过的知识点,其它略过...). Digester类作用 使用sax技术对xml进行解析 未开始解析时Digester.push(this)这个用来 ...

  9. ethereumjs/merkle-patricia-tree-2-API

    SecureTrie src/secure.js:10-15 Extends Trie 扩展前缀树 You can create a secure Trie where the keys are au ...

随机推荐

  1. [gcc warnings] -Wtrigraph warnings

    [gcc warnings] -Wtrigraph warnings 背景 三字符组(trigraph)与双字符组(Digraph)是程序设计语言(如C语言)中3个或者2个字符的序列,在编译器预扫描源 ...

  2. LEFT JOIN与RIGHT JOIN学习笔记

    SELECT COUNT(*) FROM [tbiz_PuzzleBasic] SELECT A.BasicID,A.Name,A.Gender,B.WorkID,B.Company,B.Positi ...

  3. Linux下卸载删除.Net Core

    最近在技术博客和技术交流群遇到很多小伙伴们在Linux下更新或者安装.Net Core SDK后dotnet命令无法识别等问题,现如下解决: 卸载SDK命令 sudo yum remove dotne ...

  4. PTA 7-2 深入虎穴 (30 分)

    著名的王牌间谍 007 需要执行一次任务,获取敌方的机密情报.已知情报藏在一个地下迷宫里,迷宫只有一个入口,里面有很多条通路,每条路通向一扇门.每一扇门背后或者是一个房间,或者又有很多条路,同样是每条 ...

  5. [ActionScript 3.0] flash中的颜色

    在 Flash 中,颜色就是一串特殊的数字,一个颜色值可以是0到16,777,215中的任意数值,这就是24位(bit)色彩.也许大家会问,为什么有16,777,216(256*256*256)种颜色 ...

  6. Linux系统如何迁移至LVM磁盘

    今天遇到一个问题,算是比较严重的把.就是要把当前系统转移到 LVM 卷里面去,下面有一些发生过程介绍. 不感兴趣可以直接跳过,看实战部分<如何迁移系统至LVM卷> 朋友今天突然找我,说是要 ...

  7. 用xpath来爬图

    # xpath语法可参考http://www.w3school.com.cn/xpath/xpath_syntax.asp# 本博客引用于https://zhuanlan.zhihu.com/some ...

  8. jmeter性能测试指标

    1.jp@gc - Actiive Threads Over Time:不同时间的活动用户数量展示(图表) 当前的时间间隔是1毫秒,在setting中可以设置时间间隔以及其他的参数 2.jp@gc - ...

  9. 北航软院2015级C#期末考试部分考题讲解

    洗洗睡了吧,我怎么知道明天的考试题目! 或者 你明年补考可以过来看看:) 晚安.

  10. 对EM算法的理解

    EM算法中要寻找的参数θ,与K-means聚类中的质心是对应的,在高斯混合模型中确定了θ,便可为样本进行类别的划分,属于哪个高斯分布的概率大就是哪一类,而这一点与K-means中的质心一样,质心确定了 ...