zoukankan      html  css  js  c++  java
  • HDU4278 Faulty Odometerd

    开始以为是容斥原理,想着做一下,应该是可以用容斥解决的,有空再过来写一下。题解是进制转换,开始没想到,不过很好理解。

    如在10进制里: 1254=  (1*10^3 + 2*10^2 + 5* 10^1+ 4*10^0)

    而faulty的大小:1254=  (1* 8^3  +  2* 8^2  +  4* 8^1+  3*8^0)  

    当然faulty里面没有3和8所以 0-9分别代表:

    int s[10]={0,1,2,3,3,4,5,6,6,7};
    #include<cstdio>
    #include<cstdlib>
    #include<iostream>
    #include<algorithm>
    #include<memory.h>
    using namespace std;
    #define LL long long 
    int s[10]={0,1,2,3,3,4,5,6,6,7};
    int main()
    {
        LL n;
        int i,j;
        while(~scanf("%lld",&n)&&n)  {
            printf("%lld: ",n);
            LL tmp=1,ans=0;
            while(n){
               ans+=s[n%10]*tmp;
               n/=10;
               tmp*=8;
            }
            printf("%lld
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    日总结07
    Flask使用json或jsonify返回响应的数据
    日总结06
    tensorflow 代码流程02
    日总结05
    题解 P1505 [国家集训队]旅游
    数学期望
    常用软件
    HTMLHelper
    DateHelper(辅助类)
  • 原文地址:https://www.cnblogs.com/hua-dong/p/7648793.html
Copyright © 2011-2022 走看看