Codeforces 1166A - Silent Classroom】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/1166/A 思路:统计所有首字母出现的次数,由贪心可知对半分最少. AC代码: #include<iostream> #include<cstdio> #include<string> using namespace std; ]; int n; string a; int main() { cin >> n; ;i < n;i++) { cin >&g…
A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There are n students in the first grade of Nlogonia high school. The principal wishes to split the students into two classroo…
链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinc…
http://codeforces.com/contest/876/problem/C C. Classroom Watch time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Eighth-grader Vova is on duty today in the class. After classes, he went into…
Content 现在有 \(n\) 名学生,我们需要将这些学生分到两个班上.对于两名在同一班级的学生,如果他们的名字首字母相同,他们就会聊天. 现在给定这些学生的名字,问最少有多少对学生会在一起聊天. 数据范围:\(1\leqslant n\leqslant 100\). Solution 这道题目主要用到贪心.具体来说,对于所有名字首字母相同的同学,将他们尽可能平均地分到两个班里面.例如,假如名字首字母为 R 的同学有 \(5\) 名,那么我们就将 \(2\) 个人分到 \(1\) 班,\(3…
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去相邻点,要走过n个点,求走过的最短距离. #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n, a, b, c; scanf("…
C. Classroom Watch time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on i…
http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: n最大1e9,那么9个9最多才加81,所以最多枚举100次,就可以找到所有符合条件的数. 代码: #include <stdio.h> #include <string.h> #include <vector> using namespace std; vector<…
题目链接:http://codeforces.com/contest/876/problem/C 题意: 定义函数:f(x) = x + 十进制下x各位上的数字之和 给你f(x)的值(f(x) <= 1e9),让你输出所有可能的x值. 题解: 部分枚举. 考虑可能的x的范围: ∵ x < f(x) ∴ 十进制下x各位上的数字之和 < 9*9 ≍ 100 所以x枚举[f(x)-100, f(x)]之间的数就好了. AC Code: #include <iostream> #in…
C. time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Eighth-grader Vova is on duty today in the class. After classes, he went into the office to wash the board, and found on it the number n.…