CodeChef SEAVOTE Sereja and Votes
2018-02-01 10:52
375 查看
题目链接:https://www.codechef.com/problems/SEAVOTE
题意:给你一堆整数,这堆数字的每一个数都可能是有一个小数向上取整而来的,问是否有一种可能的原数和为100
思路:就是判断一下啦,如果总和减去数字个数都比100大(或等于)就NO,如果当前比100小也NO,注意特判0(有0的是不可能有某个数向上取整来的。)
AC代码:#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int sum = 0;
int cnt = n;
for (int i = 0; i < n; i++) {
int b;
scanf("%d", &b);
if (!b) {
cnt--;
}
sum += b;
}
if (sum - cnt < 100 && sum >= 100) {
printf("YES\n");
}
else {
printf("NO\n");
}
}
return 0;
}
题意:给你一堆整数,这堆数字的每一个数都可能是有一个小数向上取整而来的,问是否有一种可能的原数和为100
思路:就是判断一下啦,如果总和减去数字个数都比100大(或等于)就NO,如果当前比100小也NO,注意特判0(有0的是不可能有某个数向上取整来的。)
AC代码:#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int sum = 0;
int cnt = n;
for (int i = 0; i < n; i++) {
int b;
scanf("%d", &b);
if (!b) {
cnt--;
}
sum += b;
}
if (sum - cnt < 100 && sum >= 100) {
printf("YES\n");
}
else {
printf("NO\n");
}
}
return 0;
}
相关文章推荐
- [计数 补集转换][阈值] Codechef SEAARC.Sereja and Arcs
- CodeChef Sereja and Game [DP 概率 博弈论]
- CodeChef Sereja and LCM(矩阵快速幂)
- codechef January Challenge 2014 Sereja and Graph
- CodeChef Sereja and GCD
- ●CodeChef Sereja and Game
- codechef Chef and The Right Triangles 题解
- Codechef Little Elephant and Painting (期望+动态规划)
- codechef Little Elephant and Permutations题解
- [DP] Codechef .Chef And Fibonacci Array
- codechef Jewels and Stones 题解
- codechef Polo the Penguin and the Tree
- Codeforces Round #215 (Div. 1) C. Sereja and the Arrangement of Numbers(欧拉图)
- codechef Jewels and Stones 题解
- [点分树] Codechef December Challenge 2017. Chef, Leonardo And Queries
- codeforces Sereja and Algorithm
- codechef:April Challenge 2014: Cards, bags and coins
- CodeChef Chef and Churu Problem
- CodeForces Round 213 Div 2 E Sereja and Brackets 线段树
- 【分块+树状数组】codechef November Challenge 2014 .Chef and Churu