Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题
B. Tavas and SaDDas
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/535/problem/B
Description
Once again Tavas started eating coffee mix without water! Keione told him that it smells awful, but he didn't stop doing that. That's why Keione told his smart friend, SaDDas to punish him! SaDDas took Tavas' headphones and told him: "If you solve the following problem, I'll return it to you."
The problem is:
You are given a lucky number n. Lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
If we sort all lucky numbers in increasing order, what's the 1-based index of n?
Tavas is not as smart as SaDDas, so he asked you to do him a favor and solve this problem so he can have his headphones back.
Input
1000000000.
Output
Sample Input
Sample Output
HINT
题意
只由4和7组成的数字是幸运数字,然后给你个幸运数字,问你是第几个
题解:
1.打表
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar('0' + buf[j]);
printf("\n");
}
*/
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
map<int,int>s;
int main()
{
string ss;
cin>>ss;
long long ans=;
long long pow=;
for(int i=ss.size()-;i>=;i--)
{
if(ss[i]=='')
{
ans+=pow*;
}
else
{
ans+=pow*;
}
pow*=;
}
cout<<ans<<endl; }
Codeforces Round #299 (Div. 2) B. Tavas and SaDDas 水题的更多相关文章
- Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题
Tavas and Karafs Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...
- Codeforces Round #299 (Div. 2) A. Tavas and Nafas 水题
A. Tavas and Nafas Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/535/pr ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- Codeforces Round #299 (Div. 2) B. Tavas and SaDDas【DFS/*进制思维/位运算/一个数为幸运数,当且仅当它的每一位要么是4,要么是7 ,求小于等于n的幸运数个数】
B. Tavas and SaDDas time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
随机推荐
- (转)USB体系结构
转载地址:http://blog.ednchina.com/zenhuateng/203584/Message.aspx USB总线接口层:物理连接.电气信号环境.信息包传输机制:主机一方由USB主控 ...
- 64_p1
PEGTL-devel-1.3.1-2.fc26.i686.rpm 13-Feb-2017 22:10 64086 PEGTL-devel-1.3.1-2.fc26.x86_64.rpm 13-Feb ...
- iTextSharp操作pdf之pdfCreater
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 011 CountDownLatch,CyclicBarrier和Semaphore
CountDownLatch(闭锁,有译倒计数,锁寄存): public class CountDownLatchTest { /*** 比如有一个任务A,它要等待其他4个任务执行完毕之后才能执行,此 ...
- javaScript-继承2种方式
1.组合继承 组合继承带来的问题很明细就是父类的构造函数会调用两次,如: function Person(name, age, sex) { this.name = name; this.age = ...
- [ python ] 初始面向对象
首先,通过之前学习的函数编写一个 人狗大战 的例子. 分析下这个需求,人 狗 大战 三个事情.角色:人.狗动作:狗咬人,人打狗 先创建人和狗两个角色: def person(name, hp, ag ...
- cgic实现输入文件名,打开文件的功能
a.c文件 #include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdarg. ...
- HDU 2544 最短路(floyd+bellman-ford+spfa+dijkstra队列优化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意:找点1到点n的最短路(无向图) 练一下最短路... dijkstra+队列优化: #i ...
- linux下redis的安装与部署
一.Redis介绍 Redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多 ...
- JAVA(一)变量
public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(" ...