题解:

  因为每一位只可能是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. 关于按下ctrl+z后,之后的cin失效的问题

    下面这代码按下Ctrl+z结束while输入后,接下来的cin >> val2就无法输入了 #include <iostream> #include <vector> ...

  2. Apache NIFI

    Add a.password file to chrome. Settings -> Advanced -> Security -> Manage Certificates -> ...

  3. 整理收集的一些常用java工具类

    1.json转换工具 package com.taotao.utils; import java.util.List; import com.fasterxml.jackson.core.JsonPr ...

  4. [AST Babel Plugin] Hanlde ArrowFunction && FunctionExpression

    Continue with previous post: https://www.cnblogs.com/Answer1215/p/12342540.html Now we need to think ...

  5. # node中的url常用方法解析

    url字符串是一个结构化的字符串,由好几个有意义部分组成.我们在工作中不可避免的会用到其中的某个部分,最原始的通过字符串截取和正则匹配的方法难免用起来会不太方便和美观,所以在我们的nodejs中提供了 ...

  6. rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装

    rancher说明为什么需要按照指定版本安装以及rancher和节点linux环境配置-docker指定版本安装 待办 https://blog.csdn.net/CSDN_duomaomao/art ...

  7. 2019牛客多校第四场A meeting 思维

    meeting 题意 一个树上有若干点上有人,找出一个集合点,使得所有人都到达这个点的时间最短(无碰撞) 思路 就是找树的直径,找直径的时候记得要找有人的点 #include<bits/stdc ...

  8. Django_模型字段属性

    """ 定义属性 概述 ·django根据属性的类型确定以下信息 ·当前选择的数据库支持字段的类型 ·渲染管理表单时使用的默认html控件 ·在管理站点最低限度的验证 · ...

  9. Iris请求方式和数据返回类型

    1. Iris起服务 package main import "github.com/kataras/iris" func main() { //1.创建app结构体对象 app ...

  10. 计算几何-RC-poj2187

    This article is made by Jason-Cow.Welcome to reprint.But please post the article's address. 今天学习一下旋( ...