Codeforces Round #308 (Div. 2)题解

电磁兼容(EMC):一文读懂过电应力(EOS) 过电应力(EOS)是指元器件承受的电流或电压应力超过其允许的最大范围。产品的电磁兼容(EMC)失效的一种常见模型为过电应力(EOS),也是电子产品失效的最常见的情况之一。过电应力基本与半导体器件相关,EOS事件包括有:静电放电(ESD)、雷击、系统瞬态、电磁脉冲、充电等。本文将详细讨论一下产品设计中如何关注EOS设计。 阅读详情

第二天补的

并不都是自己写的

参考了别人的题解

感觉这次cf题意好懂

就是做起来嘛。。

毕竟我还太弱。。

只为落实微笑


A. Vanya and Table
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.

In this table, Vanya chose n rectangles with sides that go along borders of squares (some rectangles probably occur multiple times). After that for each cell of the table he counted the number of rectangles it belongs to and wrote this number into it. Now he wants to find the sum of values in all cells of the table and as the table is too large, he asks you to help him find the result.

Input

The first line contains integer n (1 ≤ n ≤ 100) — the number of rectangles.

Each of the following n lines contains four integers x1, y1, x2, y2 (1 ≤ x1 ≤ x2 ≤ 100, 1 ≤ y1 ≤ y2 ≤ 100), where x1 and y1 are the number of the column and row of the lower left cell and x2 and y2 are the number of the column and row of the upper right cell of a rectangle.

Output

In a single line print the sum of all values in the cells of the table.

Sample test(s)
input
2
1 1 2 3
2 2 3 3
output
10
input
2
1 1 3 3
1 1 3 3
output
18
Note

Note to the first sample test:

Values of the table in the first three rows and columns will be as follows:

121

121

110

So, the sum of values will be equal to 10.

Note to the second sample test:

Values of the table in the first three rows and columns will be as follows:

222

222

222

So, the sum of values will be equal to 18.



题意:给两个点坐标算矩形面积之和



#include "iostream"
#include "cstdio"
#include "cmath"
#include "algorithm"
using namespace std;
int main(int argc, char const *argv[])
{
	int n, a, b, c, d;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a >> b >> c >> d;
		ans += abs(c - a + 1) * abs(d - b + 1);
	}
	cout << ans << endl;
	return 0;
}




B. Vanya and Books
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.

Vanya wants to know how many digits he will have to write down as he labels the books.

Input

The first line contains integer n (1 ≤ n ≤ 109) — the number of books in the library.

Output

Print the number of digits needed to number all the books.

Sample test(s)
input
13
output
17
input
4
output
4
Note

Note to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.

Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits.



题意:给一个n判断1~n有多少个数 eg: 13有17个数 分别是:1,2,3,4,5,6,7,8,9,1,0,1,1,1,2,1,3


思路:一个数组保存个数 另外加一下零头多少个就好了


AC代码:



#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "cmath" 
using namespace std;
 
int n;
long long f[12];
long long t[12];
int main() {
    cin >> n;
    t[1] = 10;
    for (int i = 2; i <= 10; i++)
        t[i] = t[i - 1] * 10;
    f[1] = 11;
    for (int i = 2; i <= 10; i++)
        f[i] = f[i - 1] + (t[i] - t[i - 1]) * i + 1;
    long long ans;
    long long base;
    for (int i = 0; i <= n; i++) {
        if (t[i] > n) {
            base = i - 1;
            break;
        }
    }
    ans = f[base] + (n - t[base]) * (base + 1);
    cout << ans << endl;
    return 0;
}<span style="color:#33cc00;">
</span>

我的代码():


判错是test5 可是我本地和oj上结果不一样  本地上的结果就是对的。。  奇怪。。


#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "queue"
#include "cmath"
using namespace std;
long long num[12] = {0};
void init()
{
    for(int i = 1; i <= 11; ++i)
        num[i] = num[i - 1] + 9 * pow(10, i - 1) * i;
}
int main(int argc, char const *argv[])
{
    int n;
    init();
    while(cin >> n) {
        int x = n, n_num = 0;
        while(x / 10) {
            n_num++;
            x /= 10;
        }
        if(n_num == 0) {
            printf("%d\n", n);
            return 0;
        }
        long long ans = num[n_num];
        ans += (n - pow(10, n_num) + 1) * (n_num + 1);      
        cout << ans << endl;
    }
    return 0;
}


C. Vanya and Scales
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2(exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m using the given weights, if the weights can be put on both pans of the scales. Formally speaking, your task is to determine whether it is possible to place an item of mass m and some weights on the left pan of the scales, and some weights on the right pan of the scales so that the pans of the scales were in balance.

Input

The first line contains two integers w, m (2 ≤ w ≤ 109, 1 ≤ m ≤ 109) — the number defining the masses of the weights and the mass of the item.

Output

Print word 'YES' if the item can be weighted and 'NO' if it cannot.

Sample test(s)
input
3 7
output
YES
input
100 99
output
YES
input
100 50
output
NO
Note

Note to the first sample test. One pan can have an item of mass 7 and a weight of mass 3, and the second pan can have two weights of masses 9 and 1, correspondingly. Then 7 + 3 = 9 + 1.

Note to the second sample test. One pan of the scales can have an item of mass 99 and the weight of mass 1, and the second pan can have the weight of mass 100.

Note to the third sample test. It is impossible to measure the weight of the item in the manner described in the input.


嗯。。 并不会做。。看题解。。

题意:用质量为w0,w1....w100的砝码乘出质量m,砝码可放天平左可放天平右

思路:假设可以称出,用w进制表示m,每一位上一定是0, 1,  w - 1, 否则就是NO,如果某一位是w-1则说明这个砝码跟物品摆在同一边,

对m的每一位模拟这个过程

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
using namespace std;
int main(int argc, char const *argv[])
{
	int n, m;
	cin >> n >> m;
	if(n == 3) {
		cout << "YES" << endl;
		return 0;
	}
	while(m) {
		int z = m % n;
		if(z <= 1)
			m /= n;
		else if(z == n - 1)
			m = m / n + 1;
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


D. Vanya and Triangles
time limit per test
4 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Vanya got bored and he painted n distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area.

Input

The first line contains integer n (1 ≤ n ≤ 2000) — the number of the points painted on the plane.

Next n lines contain two integers each xi, yi ( - 100 ≤ xi, yi ≤ 100) — the coordinates of the i-th point. It is guaranteed that no two given points coincide.

Output

In the first line print an integer — the number of triangles with the non-zero area among the painted points.

Sample test(s)
input
4
0 0
1 1
2 0
2 2
output
3
input
3
0 0
1 1
2 0
output
1
input
1
1 1
output
0
Note

Note to the first sample test. There are 3 triangles formed: (0, 0) - (1, 1) - (2, 0); (0, 0) - (2, 2) - (2, 0); (1, 1) - (2, 2) - (2, 0).

Note to the second sample test. There is 1 triangle formed: (0, 0) - (1, 1) - (2, 0).

Note to the third sample test. A single point doesn't form a single triangle.


题意:给出n个坐标,问能构成几个三角形

嗯。。还是看题解。。

思路:总方案数为n^3之和(数学公式),枚举每一个点,计算这个点与其他所有点的斜率,三点共线则斜率会相等,减去相等斜率m个点m^2之和

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "vector"
#include "cmath"
using namespace std;
const double inf = 1e10;
const double eps = 1e-8;
typedef long long ll;
struct point
{
	/* data */
	int x, y;
	point() {};
	point(int a, int b): x(a), y(b) {}
};
int n;
point p[2005];
int main(int argc, char const *argv[])
{
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> p[i].x >> p[i].y;
	if(n < 3) {
		cout << 0 << endl;
		return 0;
	}
	ll tot = (ll)n * (n - 1) * (n - 2) / 6;
	ll sum = 0;
	vector<double> ans;
	for(int i = 0; i < n; ++i) {
		ans.clear();
		for(int j = i + 1; j < n; ++j) {
			int dx = p[j].x - p[i].x;
			int dy = p[j].y - p[i].y;
			double k;
			if(dx == 0) k = inf;
			else if(dy == 0) k = 0.0;
			else k = (double)dy / (double)dx;
			ans.push_back(k);
		}
		sort(ans.begin(), ans.end());
		double num = ans[0];
		int cnt = 0;
		for(int j = 0; j < ans.size(); ++j)
			if(fabs(ans[j] - num) < eps) cnt++;
			else {
				sum += (ll)cnt * ((ll)cnt - 1ll) / 2;
				cnt = 1;
				num = ans[j];
			}
		sum += (ll)cnt * ((ll)cnt - 1ll) / 2;
	}
	cout << tot - sum << endl;
	return 0;
}


E. Vanya and Brackets
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vanya is doing his maths homework. He has an expression of form , where x1, x2, ..., xn are digits from 1 to 9, and sign  represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of brackets in this expression so that to maximize the value of the resulting expression.

Input

The first line contains expression s (1 ≤ |s| ≤ 5001, |s| is odd), its odd positions only contain digits from 1 to 9, and even positions only contain signs  +  and  * .

The number of signs  *  doesn't exceed 15.

Output

In the first line print the maximum possible value of an expression.

Sample test(s)
input
3+5*7+8*4
output
303
input
2+3*5
output
25
input
3*4*5
output
60
Note

Note to the first sample test. 3 + 5 * (7 + 8) * 4 = 303.

Note to the second sample test. (2 + 3) * 5 = 25.

Note to the third sample test. (3 * 4) * 5 = 60 (also many other variants are valid, for instance, (3) * 4 * 5 = 60).



题意:给出一个表达式只含有加号+和乘号*,数字是1~9,让你加一个括号,使得表达式值最大,看这个就知道肯定用栈(说的好像我会一样)

思路:左括号在乘号右边,右括号在乘号左边保证最大。枚举括号位置并计算。

AC代码:

#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "stack"
#include "vector"
#include "string"
using namespace std;
typedef long long ll;
int n;
string str;
vector<int> pos;
stack<char> sc;
stack<ll> sn;

ll tworesult(ll a, ll b, char c) {
	return (c == '*') ? a * b : a + b;
}
void cal() {
	char t = sc.top();
	sc.pop();
	ll a = sn.top();
	sn.pop();
	ll b = sn.top();
	sn.pop();
	sn.push(tworesult(a, b, t));
}
ll expression(string s) {
	for(int i = 0; i < s.length(); ++i) {
		char c = s[i];
		if(isdigit(c)) sn.push(c - '0');
		else if(c == '(') sc.push(c);
		else if(c == ')') {
			while(sc.top() != '(') cal();
			sc.pop(); 
		}else {
			if(c == '+') {
				while(!sc.empty() && sc.top() == '*') cal();
				sc.push(c);
			}else sc.push(c);
		}
	}
	while(!sc.empty()) cal();
	return sn.top();
}
int main(int argc, char const *argv[])
{
	cin >> str;
	n = str.size();
	pos.push_back(-1);
	for(int i = 1; i < n; i += 2)
		if(str[i] == '*') pos.push_back(i);
	pos.push_back(n);
	int len = pos.size();
	ll ans = 0;
	for(int i = 0; i < len - 1; ++i)
		for(int j = i + 1; j < len; ++j) {
			string s = str;
			s.insert(pos[i] + 1, 1, '(');
			s.insert(pos[j] + 1, 1, ')');
			ans = max(ans, expression(s));
		}
	cout << ans << endl;
	return 0;
}



OpenClaw 超级 AI 实战专栏【实战案例】(五)邮件收发 + 日历日程 + 文件管理一站式搞定 OpenClaw 实现办公自动化核心是模块解耦:邮件收发、文件管理、日历日程各自封装,便于维护和扩展;开发中需重点解决编码兼容、权限配置、时间格式、重复处理四大类坑点,核心思路是 “提前校验 + 异常兜底 + 统一格式”;敏感信息(邮箱密码、API Token)务必通过.env管理,避免硬编码泄露。 阅读详情

相关推荐

WEBGL Shader零基础教程(四):片元着色器核心逻辑

本文系统介绍了WebGL渲染管线中片元着色器的核心概念与应用。主要内容包括:1)片元着色器在渲染管线中的定位与作用,作为逐像素处理单元接收插值数据并计算最终颜色;2)输入数据类型与使用规则,重点讲解varying变量和uniform变量的应用场景;3)颜色计算的核心逻辑,涵盖基础色、渐变、纹理采样和颜色混合;4)进阶特效实现与性能优化技巧,包括交互效果、内置函数组合和GPU计算优化;5)通过综合案例演示了纹理、波纹与交互效果的整合实现。文章提供了完整的代码示例和调试建议,为后续学习光照模型、后期处理等高级渲

分享知识,拥抱变化 1393

A sequence of numbers (入门题-数学)

A sequence of numbers                                                                                   Time Limit: 1 Seconds    Memory Limit: 32 Mbyte 题目描述:       Xinlv wrote some sequences on t

2571

AI人工智能与TensorFlow的教育科技应用

随着科技的飞速发展,AI人工智能在各个领域都展现出了巨大的潜力,教育领域也不例外。本文章的目的在于深入探讨AI人工智能与TensorFlow在教育科技中的具体应用,包括智能教学系统的开发、学生学习情况的评估与预测等方面。范围涵盖了从基础概念到实际项目应用的各个层面,旨在为教育科技工作者和相关研究者提供全面且深入的技术指导。本文将首先介绍AI人工智能和TensorFlow的核心概念及其联系,让读者对相关技术有基本的了解。接着详细讲解核心算法原理和具体操作步骤,并结合数学模型和公式进行深入分析。

AI智能探索者的博客 1713

Day5-T4

原题目   Describe:最小生成树加权   code: #include<bits/stdc++.h> #define INF 214748364 #define eps 1e-9 #define rep1(a,b) for(register long long i=(a);i<=(b);i++) #define rep2(a,b) for(registe...

weixin_30920597的博客 119

SAP COPA实战:手把手教你用CMOD增强搞定自定义特性派生(以客户字段为例)

本文详细介绍了在SAP COPA模块中通过CMOD增强实现自定义特性派生的全流程,以客户字段为例,展示了从特性设计、SPRO配置到特性派生逻辑实现的完整步骤。重点讲解了如何利用CMOD增强技术解决业务需求,提升获利能力段分析的灵活性和准确性。

weixin_30275415的博客 438

《YOLOv8-seg改进》专栏指导书册 &手把手创新教程

学姐带你学习YOLOv8,从入门到创新,轻轻松松搞定科研;1)手把手教你如何训练YOLOv8-seg;2)模型创新,提升分割性能;3)独家自研模块助力分割;

会AI的学姐 3826

Codeforces Round #308 (Div. 2)

再次厚颜无耻地宣传一发:新博客http://shijieyywd.com/?p=99这次cf真是发挥的有点醉,下次有div1我都不敢做了。A. Vanya and Table给你n个矩形,问你面积之和。是面积之和不是面积并,直接算。然而我这个傻逼交错文件了WA了一发233333。#include <bits/stdc++.h>using namespace std;int n; int main()

Shion的专栏 1533

PreScan快速入门到精通第十一讲之PreScan道路标记,建筑物、抽象物体及交通标识

道路标记目的:路标是为了完善智能驾驶实验场景。用途:道路标记是附加在道路段上的。标记的大小{小、大}、颜色,以及相对于路段的位置和方向可以在属性编辑器中设置。也可以指定褪色和孔洞,类似于路段自动添加标记的配置。在GUI中的位置:作为一个预定义的库元素格式:NAMBOX: 汇编表中不知道。PreScan包含三个不同国家的标记:荷兰、日本和美国。可以通过在国家首选项中切换国家来隐藏或显示。附件道路标线附在路段上,并相对于路段原点定位。默认情况下,道路标记被固定在路段上,用小锚点表示。11.2 建筑物目...

小明师兄的博客 1813

水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

题目传送门 1 /* 2 水题:读懂题目就能做 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 #i...

weixin_30289831的博客 70

python ERA-5气象数据NetCDF格式解析(一)

python ERA-5气象数据NetCDF格式解析

weixin_43896283的博客 2641

binning模式下和normal模式下相同曝光参数相同场景加权亮度差异消除方案优化(一)

摘要:针对ISP参数设置中浮点权重系数需转换为整数的问题,提出整数邻域搜索方案。该方法在浮点最优解附近(±1/±2)进行局部搜索,通过逐阶微调找到误差最小的整数权重组合,避免直接取整导致的误差反弹(误差从0.8%降至0.35%)。方案结合范围约束(1~15)和单调性约束(暗端递减、亮端递增),兼顾计算效率(单图耗时<10ms)与硬件兼容性,显著优于暴力搜索和简单取整,满足工程落地需求。

大熊 102

Codeforces Round #308 (Div. 2) B. Vanya and Books

http://www.codeforces.com/problemset/problem/552/B题意:给你一个数N,问你从1到N所有的数的数字位数之和为多少。 解法: 不难看出,数对应的数字位数分别为: 1-9 1 10-99 2 100-999 3 …

Accepted丶 398

SAP UI5 主题设置全解析:从启动参数到运行时切换、跨域白名单与事件监听

SAP UI5主题体系深度解析:从配置到切换的完整指南 摘要:SAP UI5主题机制远不止CSS换肤,其工程化实践涵盖启动配置、运行时API切换、跨库路径映射及安全管控等关键环节。通过bootstrap标签或URL参数设置初始主题,运行时可用Theming.setTheme无刷新切换。自定义主题需配置theme-roots路径,跨域加载需声明sap-allowed-theme-origins白名单。主题切换完成后会触发applied事件,适合执行视觉同步操作。该体系支持多品牌适配、集中式主题管理,在Fior

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 333

数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

题目传送门 1 /* 2 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <algorithm> 7 #include <cstring> 8 #in...

weixin_33807284的博客 77

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Codeforces Round #308 (Div. 2) Vanya and Books

题目链接:http://codeforces.com/contest/552/problem/B 题意:就是求有几个数字; eg:13:1 2 3 4 5 6 4 7 8 9 1 0 1 1 1 2 1 3 一共17个数字#include <iostream>using namespace std; long long a[12]={0,9,99,999,9999,99999,999999

代码改变世界 870

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Codeforces Round #308 (Div. 2) C.Vanya and Scales

Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w100 grams where w is some integer not less than 2(exactly one weight of each nominal value). Vanya wonders whether he

lljjccsskk的专栏 350

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Codeforces Round #308 (Div. 2) A、B

552A - Vanya and Table 这题没什么好说的了,题目读懂了直接模拟就可以了。#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> using namespace std; int g[105][105]; int gao(int x, int y, int xx, int y

Freeway的博客 694

Codeforces Round #308 (Div. 2) A. Vanya and Table

题目链接:http://codeforces.com/contest/552/problem/A hint: 就是求几个矩形的面积#include <iostream> #include <cmath> using namespace std; struct point { int x; int y; }a[2]; int main() { int m; while

代码改变世界 839

Codeforces Round #308 (Div. 2) E. Vanya and Brackets

Vanya is doing his maths homework. He has an expression of form , where x1, x2, …, xn are digits from 1 to 9, and sign represents either a plus ‘+’ or the multiplication sign ‘*’. Vanya needs to add ...

loooooog的博客 181
上一篇: ssanf
下一篇: NOJ1057 封杀病毒(pow & sqrt函数的原型)
GKHack
博客等级 码龄12年 48粉丝 291原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址