Codeforces GYM 100114 C. Sequence 打表
C. Sequence
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/gym/100114
Description
Integer sequences are very interesting mathematical objects. Let us examine a sequence generated with the use of two operations: doubling and “digit sorting”. The latter operation consists in ascending-order sort of the individual digits in the decimal representation of the argument. For example, “digit sorting” of number 5726 gives 2567. The first member of the considered sequence is 1. To generate a member of the sequence from the previous member, double the previous one and apply “digit sorting” to the result. The first 15 members of the sequence are as follows: 1, 2, 4, 8, 16, 23, 46, 29, 58, 116, 223, 446, 289, 578, 1156, … Write a program to determine the value of the n-th member of this sequence.
Input
Output
Sample Input
1
Sample Output
HINT
题意
1, 2, 4, 8, 16, 23, 46, 29, 58, 116, 223, 446, 289, 578, 1156
规律是上一个,是前一个数乘以2之后,数字按字典序排列之后的样子
题解:
打表之后,发现后面都是6个一个循环的,直接输出就好了
代码:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm> using namespace std; int a[]={,,,,,,,,,,,,,,,,,,,,,,,,};
int b[]={,,,,,};
int n; int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d",&n);
if(n<=) printf("%d\n",a[n]);
else printf("%d\n",b[(n-)%]);
return ;
}
Codeforces GYM 100114 C. Sequence 打表的更多相关文章
- Codeforces Gym 100114 H. Milestones 离线树状数组
H. Milestones Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descripti ...
- Codeforces GYM 100114 D. Selection 线段树维护DP
D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descriptio ...
- codeforces GYM 100114 J. Computer Network 无相图缩点+树的直径
题目链接: http://codeforces.com/gym/100114 Description The computer network of “Plunder & Flee Inc.” ...
- codeforces GYM 100114 J. Computer Network tarjan 树的直径 缩点
J. Computer Network Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Des ...
- Codeforces GYM 100114 B. Island 水题
B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...
- Codeforces Gym 100114 A. Hanoi tower 找规律
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...
- Codeforces Gym 100418K Cards 暴力打表
CardsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action? ...
- Codeforces Gym 100114 D. Selection
Description 问选择一个序列上的所有数的最少操作次数,跟电脑上选择文件一样,输出操作方案. Sol 贪心. 用Shift一段文件只能使用一次,之后必须一直按Ctrl了. 然后就是看用Shif ...
- Codeforces Gym 100114 J. Computer Network
Description 给出一个图,求添加一条边使得添加后的图的桥(割边)最少. Sol Tarjan. 一遍Tarjan求割边. 我们发现连接的两个点一定是这两个点之间的路径上的桥最多,然后就可以贪 ...
随机推荐
- 在android中进行视频的分割
最近项目有个需求要对录制的视频进行分割,查了很多资料,看到ffmpeg可以对视频进行分割.上网找到别人基于android的开源ffmpeg,终于编译成功ffmpeg.so.但是要使用的话还要查ffmp ...
- POJ 2481 Cows
Cows Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 16546 Accepted: 5531 Description ...
- UI特效--Android利用ViewFlipper实现屏幕切换动画效果
.屏幕切换指的是在同一个Activity内屏幕见的切换,最长见的情况就是在一个FrameLayout内有多个页面,比如一个系统设置页面:一个个性化设置页面.2.介绍ViewFilpper类ViewFl ...
- IOS UIActivityIndicatorView 等待指示器
自己做的一个 等待指示器 #import <UIKit/UIKit.h> @interface RockIndicatorView : UIView { } @property(nonat ...
- 使用DDMS测试安卓手机APP的性能(android)
安装/配置: 通过另外一个工具也可以测试手机客户端APP的性能,这就是android开发包中的DDMS工具(Dalvik Debug Monitor Service),先来说一下android开发包的 ...
- qt 在指定区域添加图片
博客出处:http://www.devdiv.com/thread-39111-1-1.html 折腾了几天,终于实现了图片的淡出淡入的效果. 其实也应该是说实现了图片的淡入效果,因为淡出效果我暂时还 ...
- 关于SecureCRT的安装和破解问题以及xp系统的串口问题
今天下午找了几个小时的软件,因为交叉编译环境要搭好,其中SecureCRT还有串口问题要解决,我突然间发现我开始光盘中的SecureCRT坏掉了,在网站上下载SecureCRT,结果要很多的积分,这样 ...
- XSLT2.0实用的新功能 .(转)
转自:http://blog.csdn.net/crystalbruce/article/details/7407631 2007年1月,W3C发布了XSLT2.0规范,2009年发布了XSLT2.1 ...
- sqlServer 取每组的前几条数据
首先的建表语句: ) DROP TABLE [test] CREATE TABLE [test] ( [id] [, ) NOT NULL , [name] [nvarchar] () NULL , ...
- bzoj 3997 [TJOI2015]组合数学(DP)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3997 [题意] 给定一个nm的长方形,每次只能使经过格子权值减1,每次只能向右向下,问 ...