Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream in("cifra1.in");
- ofstream out("cifra1.out");
- int main()
- {
- int n, cif, min1 = 1000000000;
- in >> n >> cif;
- int put = 1;
- while(put <= n)
- {
- int nr_nou;
- nr_nou = n / put;
- nr_nou = nr_nou * 10 + cif;
- nr_nou = nr_nou * put + (n % put);
- if(nr_nou < min1)
- min1 = nr_nou;
- put *= 10;
- }
- if(n + cif * put < min1)
- min1 = n + cif * put;
- out << min1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment