Codeforces Round #291 (Div. 2)
来源:互联网 发布:淘宝卖家诈骗800 编辑:程序博客网 时间:2024/05/19 02:04
Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9?-?t.
Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.
The first line contains a single integer x (1?≤?x?≤?1018) — the number that Luke Skywalker gave to Chewbacca.
Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.
27
22
4545
4444
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
char s[20];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
cin>>s;
int l=strlen(s);
int num=0;
for(int i=0;i<l;i++)
{
if(i==0&&s[i]=='9')continue;
int t=s[i]-'0';
t=min(t,9-t);
s[i]=(char)t+'0';
}
cout<<s<<endl;
return 0;
}
//一开始拒绝这么写的。。直到wrong 了5次
- Codeforces Round #291 (Div. 2)
- Codeforces Round #291 (Div. 2)
- Codeforces Round #291 (Div. 2)
- Codeforces Round #291 (Div. 2)
- Codeforces Round #291 (Div. 2)
- 【codeforces】Codeforces Round #291 (Div. 2) 题解
- Codeforces Round #291 (Div. 2)(A,B)
- Codeforces Round #291 (Div. 2)(C)
- Codeforces Round #291 (Div. 2)(B)
- Codeforces Round #291 (Div. 2)(A)
- Trie(Codeforces Round #291 (Div. 2))
- Codeforces Round #291 (Div. 2)(D)
- Codeforces Round #291 (Div. 2) ABC
- Codeforces Round #291 (Div. 2) 题解
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #295 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #293 (Div. 2)
- Codeforces Round #292 (Div. 2)
- IOS中NSUserDefaults的用法
- Codeforces Round #291 (Div. 2)
- HDU 2181 哈密顿绕行世界问题
- POJ 1426 Find The Multiple
- POJ 3984 迷宫问题
- HDU 2612 Find a way
- 字典树(trie 树)
- intellij idea15 破解
- UVa 11732 - strcmp() Anyone?
- POJ 3630 Phone List