Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
shivratri
#include<bits/stdc++.h> #include<string> using namespace std; #define SCD(t) scanf("%d",&t) #define SCLD(t) scanf("%ld",&t) #define SCLLD(t) scanf("%lld",&t) #define SCC(t) scanf("%c",&t) #define SCS(t) scanf("%s",t) #define SCF(t) scanf("%f",&t) #define SCLF(t) scanf("%lf",&t) #define MEM(a, b) memset(a, (b), sizeof(a)) #define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in) #define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in) void solve(string s,long int d) { long int l=s.size(),j=0,i,a[l]; for(i=0;i<l;i++) { a[i]=s[i]; } if(a[l-1]>d) { a[l-1]=d; } for(i=0;i<l-1;i++) { if(a[i]>a[j+1]) { if(a[i]==0) { while(a[i]==0) { j++;} i=0; } a[i]=0; i=0; j++; } } for(i=0;i<l;i++) cout<<a[i]; } int main() { int t; SCD(t); while(t--) { long int n,d; SCLD(n); SCLD(d); string s; s=to_string(n); solve(s,d); } }
run
|
edit
|
history
|
help
0
ApelRefVal
TwoVarRegression
Caminho das Pontes
Atul
at.cpp
IceCream
Test 7(2020)
LIS
weak_ptr and Circle_reference
Heap DS and Heapsort