Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main(){
- string s;
- cin >> s;
- int pow = 8;
- int number = 0;
- for(int i = 1; i < s.size(); i++) {
- number += pow;
- pow *= 9;
- }
- pow /= 8;
- for(int i = 0; i < s.size(); i++) {
- int cifra = s[i] - '0';
- int moznosti = 0;
- if(i == 0) {
- if(cifra <= 6) {
- moznosti = cifra - 1;
- }
- else {
- moznosti = cifra - 2;
- }
- }
- else {
- if(cifra <= 6) {
- moznosti = cifra;
- }
- else {
- moznosti = cifra - 1;
- }
- }
- number += moznosti * pow;
- pow /= 9;
- }
- cout << number + 1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment