刚才abc 的 b,c题求助
  • 板块学术版
  • 楼主XYzero
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/3/16 22:23
  • 上次更新2024/3/17 08:45:16
查看原帖
刚才abc 的 b,c题求助
917025
XYzero楼主2024/3/16 22:23

样例都过了,两道题都莫名其妙 WA 了

B:

#include<bits/stdc++.h>
using namespace std;
int main(){
	double x;
	cin >> x;
	double t = 10.0;
	long long ans = ceil(x / t);
	cout << ans << " ";
	return 0;
}

C:

#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
#define int long long
int h[N][30],ans;
signed main(){
    string s;
    cin >> s;
    int n = s.size() - 1;
	//n - 1 + n - 2 .....
	bool flg = false;
	for(int i = n;i >= 0;i--){
		h[i][s[i] - 'a'] = h[i + 1][s[i] - 'a'] + 1;
		if(h[i][s[i] - 'a'] > 1 && flg == false){
			flg = true;
			ans = 1;
		}
	}
	for(int i = 0;i <= n;i++){
		ans += (n - i);
		if(h[i][s[i] - 'a'] != 0){
			ans -= h[i][s[i] - 'a'];
			ans ++;
		}
	}
	cout << ans;
	return 0;
}
2024/3/16 22:23
加载中...