本文主要是介绍HDU 4278 Faulty Odometer [模拟],希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
把乱了以后的数码映射到真实的数码,然后就8进制转10进制。
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
inline int Rint() { int x; scanf("%d", &x); return x; }
inline int max(int x, int y) { return (x>y)? x: y; }
inline int min(int x, int y) { return (x<y)? x: y; }
#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(x) for(int i=0; i<(x); i++)
typedef long long int64;
#define INF (1<<30)
const double eps = 1e-8;
#define bug(s) cout<<#s<<"="<<s<<" "#define MAXN 20
char a[MAXN];
int bak;int b[] = { 0, 1, 2, 3, 3, 4, 5, 6, 7, 7, 8 };int main()
{while(scanf("%s", a)!=-1){if(a[0] == '0') break;bak = 0;for(int i=0; a[i]; i++){bak = bak*10+a[i]-'0';a[i] = b[a[i]-'0']+'0';}int ans;sscanf(a, "%o", &ans);printf("%d: %d\n", bak, ans);}
}//%o
这篇关于HDU 4278 Faulty Odometer [模拟]的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!