Terrible_4

在这里插入图片描述

#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

vector<int> table() {
	//0-10^10
	vector<int> table(10);
	for (int i = 0; i < 10; ++i) {
		if (i < 2) {
			table[i] = 0;
		}
		else {
			table[i] = table[i-1] + table[i - 1] * 8 + (int)pow(10, i - 2);
		}
	}
	return table;
}

int main() {
	vector<int> t = table();
	/*
	for (int i = 0; i < t.size(); ++i) {
		cout << "<" << i << ">:" << t[i] << endl;
	}*/
	long num;
	while (cin >> num) {
		long num_begin = num;
		vector<int> n;
		while (num > 0) {
			n.push_back((int)(num % 10));
			num = num / 10;
		}
		vector<int> n_res;//逆置
		for (int i = n.size() - 1; i >= 0; --i) {
			n_res.push_back(n[i]);
		}

		long sum = 0;//带4的数字总数
		for (int i = n_res.size() - 1; i >= 0; --i) {

			while (n[i] > 0) {
				if (n[i] == 4) {
					//cout << "4444" << endl;
					sum += pow(10, i);
				}
				else {
					sum += t[i + 1];
					//cout << "i:" << i << " "<<"sum:"<<sum<<endl;
				}
				--n[i];
			}
		}
		//cout << "4_sum:" << sum << endl;
		cout << num_begin - sum << endl;
	}
}
Sure, 以下是您要求的20条关于Reviewer的数据: (4, "Alex", "2021-05-12", "The service was great, but the food was just ok.") (3, "Maggie", "2021-05-14", "The atmosphere was nice but I found the staff to be a bit unfriendly.") (5, "John", "2021-05-16", "Amazing experience, highly recommend!") (2, "Emily", "2021-05-18", "I was disappointed with the quality of the food.") (4, "Mike", "2021-05-20", "Good service and decent food.") (3, "Rachel", "2021-05-22", "The pricing was a bit high for the portion size.") (5, "David", "2021-05-24", "Absolutely amazing, will definitely be back!") (1, "Sarah", "2021-05-26", "Terrible service and mediocre food.") (4, "Brian", "2021-05-28", "The drinks were excellent, but the food was just okay.") (3, "Karen", "2021-05-30", "The atmosphere was okay, but the food was disappointing.") (5, "Jack", "2021-06-01", "Great food, excellent service!") (2, "Linda", "2021-06-03", "The service was poor and the food was not great.") (4, "Tom", "2021-06-05", "I loved the decor and the food was good.") (3, "Amanda", "2021-06-07", "The portions were small for the price.") (5, "Steve", "2021-06-09", "Outstanding, can't wait to come back!") (1, "Jessica", "2021-06-11", "Disappointing all around.") (4, "Patrick", "2021-06-13", "I really enjoyed my meal, would recommend.") (3, "Michelle", "2021-06-15", "The service was slow and the food was just okay.") (5, "Kevin", "2021-06-17", "One of the best dining experiences I have ever had!") (2, "Susan", "2021-06-19", "I would not recommend this restaurant to others.")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值