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;
}

  

 

最新文章

  1. Working in Singapore
  2. 微信小程序之后台https域名绑定以及免费的https证书申请
  3. SVN 使用锁实现独占式签出
  4. ACM训练场
  5. JS自总结
  6. iOS开发 字符串添加行间距
  7. javascript 中 in操作符
  8. .net 自然排序方式
  9. hdu 3849 (双联通求桥)
  10. 拍照返回的bitmap太小
  11. Linux服务器监控系统 ServMon V1.1---张宴
  12. iOS自动打发布包-备用
  13. Struts2 标签库详解2
  14. sudoers权限管理
  15. react-native-scrollable-tab-view 中嵌套了react-native-swiper产生的bug
  16. C. Rectangles
  17. 【C++】拷贝构造函数(深拷贝,浅拷贝)详解
  18. 浅谈 Web 缓存
  19. Eclipse 不能build, pom文件上面有叉叉 解决办法
  20. Android Bander设计与实现 - 设计

热门文章

  1. Ubuntu sudo apt-get update提示 Failed to fetch,解决办法
  2. Redis协议规范(译文)
  3. System.Data.OracleClient.dll方式操作oracle数据库
  4. Webserver asp配置及伪静态设置
  5. coderfoces D. Gourmet choice
  6. Mysql内置功能《五》 函数
  7. “全栈2019”Java第四十章:this关键字
  8. vm虚拟机安装,配置与使用
  9. Ionic2的CLI的命令行
  10. Linux系统查找清理磁盘大文件方法