社区讨论

求调

P9538 「AWOI Round 2 A」最大和参与者 2已保存回复 3

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
3 条
当前快照
1 份
快照标识符
@lo1to7lo
此快照首次捕获于
2023/10/23 02:48
2 年前
此快照最后确认于
2023/11/03 03:22
2 年前
查看原帖
自测全过,提交全WA
CPP
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<list> 
#include<queue>
using namespace std;
const double pi = 3.1415926535897932385;
typedef long long ll;
typedef pair<int,int> Pr;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, eps=2e4+10, maxn=1e6+10;
template <typename T> inline void read(T &x) {
	x = 0;
	bool flag = false;
	char ch = getchar();
	while (ch < '0' || ch > '9') flag = ch == '-' ? true : false, ch = getchar();
	while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
	if(flag) x = -x;
}
template <typename T> inline void write(T x) {
	if(x<0) {
		putchar('-');
		x = -x;
	}
	if(x>9) write(x / 10);
	putchar(x % 10 + '0');
}
ll t, n;
ll n1;
int main() {
    read(t);
    while(t--){
    	ll ans_0 = 0;
    	ll ans_9 = 0;
    	ll cnt = 0;
    	ll m = 0;
    	read(n);
    	if(n == 0){
    		printf("1");
    		continue;
		}
		n1 = n;
    	while(n != 0){
    		ll x = n % 10;
    		cnt += x;
    		if(x == 0){
    			ans_0++;
			}
			if(x == 9){
				ans_9++;
			}
			n /= 10;
			m++;
		}
		printf("%lld\n", (cnt + ans_0 * 8 + (m - ans_0 - ans_9)));
	}
	return 0;
}

回复

3 条回复,欢迎继续交流。

正在加载回复...