Untitled
unknown
plain_text
2 years ago
2.6 kB
11
Indexable
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define ppb pop_back
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define ld long double
#define sz() size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(n) f(i,0,n)
#define fj(n) f(j,0,n)
#define pii pair<ll,ll>
#define mem0(a) memset(a,0,sizeof(a))
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define debug(x) cout << #x << " is " << x << endl
#define in(n) ll n; cin>>n
#define ed <<endl
#define cntbit(x) __builtin_popcountll(x)
// #define bit(m) bitset<ll m>
typedef set<ll> si;
typedef unordered_set<ll> usi;
typedef set<char> sc;
typedef unordered_set<char> usc;
typedef vector<ll> vi;
typedef vector<char> vc;
typedef vector<ll>::iterator vit;
typedef priority_queue<ll> pqi;
typedef unordered_map<ll,ll> umii;
typedef map<ll,ll> mii;
const int N=1e9+7;
const int MaxValueOfint=INT_MAX;
const int MinValueOfint=INT_MIN;
const ll MaxValueOfLLint=LLONG_MAX;
const ll MinValueOfLLint=LLONG_MIN;
//sorting the vector of pairs by second element of pairs 'sort(all(v),sortbysec)'
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
return (a.second < b.second);
}
/*******************************************************************************/
void solve(){
string s;
cin>>s;
ll n = s.size();
vector<int> ans(n+1,0);
fi(n){
ans[i+1] = s[i]-'0';
}
ll val=0;
for(ll i=0;i<n;i++){
ll x=ans[i];
ll y=ans[i+1];
if(y==9 && x>=4 && x<9){
ans[i]+=2;
val=0;
} else if (y==9 && x<4 && x>=0){
ans[i]++;
val=ans[i];
} else if(x==9){
ans[i]=val;
} else if(y>=5 && x)
}
bool flag=true;
for(ll i=0;i<n+1;i++){
if(ans[i]=='0' && flag){
continue;
} else {
flag = false;
cout<<ans[i];
}
}
}
/*******************************************************************************/
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int hui=1;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin>>hui;
while(hui--) solve();
return 0;
}Editor is loading...