[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
成绩统计
小蓝给学生们组织了一场考试,卷面总分为100 分,每个学生的得分都是一个0 到100 的整数。
如果得分至少是60 分,则称为及格。如果得分至少为85 分,则称为优秀。
请计算及格率和优秀率,用百分数表示,百分号前的部分四舍五入保留整数。
输入格式
输入的第一行包含一个整数n,表示考试人数。
接下来n 行,每行包含一个0 至100 的整数,表示一个学生的得分。
输出格式
输出两行,每行一个百分数,分别表示及格率和优秀率。
百分号前的部分四舍五入保留整数。
输入样例
7 80 92 56 74 88 100 0
输出样例
71% 43% #include <iostream> #include <bits/stdc++.h> #include <algorithm>
#include <vector> #include <cmath> #include <queue> #include <bitset> using
namespace std; typedef long long ll; int main() { int n, jige = 0, youxiu = 0;
cin >> n; int m = n; while(n --) { int a; cin >> a; if(a >= 60) jige ++; if(a
>= 85) youxiu ++; } double sum1 = jige * 1.00 / m * 100; double sum2 = youxiu *
1.00 / m * 100; printf("%.0lf%\n%.0lf%\n",sum1, sum2); return 0; }
子串分值和
对于一个字符串S ,我们定义S 的分值f (S ) 为S 中出现的不同的字符个数。
例如f (”aba”) = 2, f (”abc”) = 3, f (”aaa”) = 1。
现在给定一个字符串S [0 : n - 1](长度为n),请你计算对于所有S 的非空子串S [i : j](0 ≤ i ≤ j < n), f (S
[i:: j]) 的和是多少。
输入格式
输入一行包含一个由小写字母组成的字符串S 。
对于所有评测用例,1 ≤ n ≤ 100000。
输出格式
输出一个整数表示答案。
输入样例
ababc
输出样例
28 #include <iostream> #include<cstring> using namespace std; typedef long
long ll; int main() { string s; cin >> s; ll total = 0; int a[26];
memset(a,-1,sizeof(a)); a[s[0] - 'a'] = 0; total += s.size(); for(int
i=1;i<s.size();i++) { total += (i - a[s[i] - 'a']) * (s.size() - i); a[s[i] -
'a'] = i; } cout << total; return 0; }