Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
shivratri
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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); } }
g++
1 4512415 3
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 1.42 sec, absolute running time: 0.07 sec, cpu time: 0.01 sec, memory peak: 3 Mb, absolute service time: 1,53 sec
edit mode
|
history
|
discussion
5253495052493