题解:

  因为每一位只可能是4或者7,可以类比二进制的思想。

  基数为2,每一位的权值为2i-1;数字4表示的大小为1*2i-1;数字7表示的大小为2*2i-1

  将给定的n按照这种方法进行分解,求和。即为答案。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std; int main(){
int n;
while(~scanf("%d",&n)){//二进制的思想
int ans=;
int index=;
while(n){
if(n%==)ans+=index;
else if(n%==)ans+=*index;
n/=;
index*=;
}
printf("%d\n",ans);
} return ;
}

数制的运用-CodeForces - 535B的更多相关文章

  1. Codeforces 535B Tavas and SaDDas 水题一枚

    题目链接:Tavas and SaDDas Once again Tavas started eating coffee mix without water! Keione told him that ...

  2. Codeforces Round #299 (Div. 2)【A,B,C】

    codeforces 535A-水题: #include <bits/stdc++.h> using namespace std; typedef long long LL; char s ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. 【Python requests多页面爬取案例】

    "```python import requests from fake_useragent import UserAgent # 随机ua库 class Boring(): def __i ...

  2. shiro中setUnauthorizedUrl("/403")不起作用

    最近学习shiro框架,在用户没有权限的情况下想让其跳转到403页面,结果非自己预想的效果.后来找到一个解决办法如下: 转载来源 SpringBoot中集成Shiro的时候, 配置setUnautho ...

  3. 题解 Fractal Streets

    题目链接 参考博客 #include<cstdio> #include<math.h> #include<utility>//pair using namespac ...

  4. 算法导论2-4 O(nlgn)时间复杂度求逆序对

    def mergesort(nums,le,ri): if le>ri-2: return 0 mi=le+(ri-le)//2 a=mergesort(nums,le,mi) b=merges ...

  5. php核心技术与最佳实践--- oop

    <?php /** * Created by PhpStorm. * User: cl * Date: 2019/8/12 * Time: 7:08 */ /*oop*/ class Perso ...

  6. crowdfunding项目01——感人的错误

    四十搭环境,半个小时下载jar包,网速感人,一个半小时找bug真是感动 首先SSM项目,主要功能进行增删改查 建立父工程和子工程,产生依赖关系 父工程:pom 子工程:jar.war(web工程) 错 ...

  7. redis本地能访问外网不能访问问题

    1.确认配置文件bind的ip是否正确,一般想要外网能访问,需要填写为0.0.0.0,表示监听任何ip 注意任何人都能访问,一定要开启密码 requirepass 你的密码 2.确认protected ...

  8. Git的基本使用 -- 分支管理

    查看分支 git branch 前面带 * 的为当前所在分支 创建分支 git branch 分支名 切换分支 git checkout 分支名 创建并切换到此分支 git checkout -b 分 ...

  9. 隐写工具F5-steganography的使用

    1.git clone https://github.com/matthewgao/F5-steganography 2.进入F5-steganography-master文件夹,在空白处 ctrl+ ...

  10. 解决win10状态栏的搜索框无法搜索本地应用或无反应

    今天突然出现的问题,在状态栏左下角的搜索框搜索OneNote没有任何反应. 1.首先,打开管理员命令窗口,win+x,可以看到弹出一个窗口,打开windows Powershell(管理员)如图 2, ...