Home Web Front-end HTML Tutorial Codeforces Round #262 (Div. 2)Problem Solution Report_html/css_WEB-ITnose

Codeforces Round #262 (Div. 2)Problem Solution Report_html/css_WEB-ITnose

Jun 24, 2016 am 11:59 AM
Report Solve problems


For details, see: http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2

1: A. Vasya and Socks http: //codeforces.com/contest/460/problem/A

There are n pairs of socks. Wear one pair every day and then throw it away. Buy a new pair of socks every m days. How many days can you go without wearing socks? .
Simple thinking questions: I didn’t pay much attention to training in this area before, but I ended up doing it for a long time. I simulated this kind of questions and thought about it myself. But think more about the trick
```c
int main(){
int n, m;
long long ans = 0;
scanf("%d%d", &n , &m);
ans = n/m*m;
int tmp = n/m;
int left = tmp n%m;
while(true){
ans = left /m*m;
tmp = left/m;
left = tmp left%m;
if(left < m) break;
}
ans = left;
printf("%I64dn", ans);
return 0;
}
```
2: B. Little Dima and Equation http://codeforces.com/contest/460/problem /B
Meaning of the question:
```mathjax
Find the solution to the equation x = b*S(x)^{a} c\
0 lt x lt 10^{9} , 1 le a le 5 , 1 le b le 10000 , -10000 le c le 10000\
s(x) is the sum of each digit of x
```
Solution: If x is simply enumerated, it must Timeout, but we can change the angle and enumerate S(x). This is much simpler. Because x can be calculated based on the right hand side..
```c

int get_sum(long long x){
int ans = 0;
while(x){
ans = x;
x /= 10;
}
return ans; %d%d%d", &a, &b, &c);
long long ans[maxn];
int num = 0;
for(int i = 1; i <= 81; i ){
long long tmp = 1;
for(int j = 1; j <= a; j ) tmp *= i;
long long temp = b*tmp c;
if (temp > 1e9) continue;
if(get_sum(temp) == i) {
ans[num ] = temp;
}
}
printf("%dn", num);
if(num > 0) {
for(int i = 0; i < num; i )
printf("%I64d ", ans[i]);
printf("n");
}
return 0;
}
```
3: C. Present http://codeforces.com/contest/460/problem/C
Question meaning: There are n flowers, given the initial height, and then water can be poured m times. Each watering can be watered with w consecutive flowers. After each watering, the flower will grow 1 unit in height. Ask what the maximum value of the shortest flower at the end is.
Solution: When you first think about it, you must first greedily select the shortest flower and water its adjacent flowers. Then a_(i) to a_(i w-1) plus one unit. I didn't think of any good way at the time, so I wanted to use a line segment tree to maintain the minimum value of the interval and find the lower bound of the minimum value every time. Then water all the flowers on the right w. I thought about it for a long time when I first found the lower bound, but I still wrote it out in conjunction with the one-dimensional situation.
```c
long long a[maxn];
long long mm[4*maxn];
int setv[4*maxn];

void build(int root, int l, int r){
int lc = 2*root, rc = 2*root 1;
if(l < r){
int mid = (l r)/2;
build(2*root, l, mid);
build(2*root 1, mid 1, r);
mm[root] = min(mm[lc], mm[rc]);
}else{
mm[root] = a[l];
}
}

void pushdown(int root, int l, int r){
int lc = 2*root, rc = 2*root 1;
if(setv[root] > 0){
setv[lc] = setv[root];
setv[rc] = setv[ root];
mm[lc] = setv[root];
mm[rc] = setv[root];
setv[root] = 0;
}
}

void pushup(int root, int l, int r){
int lc = 2*root, rc = 2*root 1;
mm[root] = min(mm[lc], mm[ rc]);
}

void modify(int root, int l, int r, int x, int y, int s){
if(x <= l && r < = y){
mm[root] = s;
setv[root] = s;
}else{
pushdown(root, l, r);
int mid = (l r )/2;
if(x <= mid) modify(2*root, l, mid, x, y, s);
if(y > mid) modify(2*root 1, mid 1, r, x, y, s);
pushup(root, l, r);
}
}

int minn;
void query(int root, int l, int r, int z){
  int lc = 2*root, rc = 2*root 1 , mid = (l r)/2;
  if(l == r){
    if(l < minn) minn = l;
  }else{
    pushdown(root, l, r);
    if(mm[lc] <= z) query(lc, l, mid, z);
    else query(rc, mid 1, r, z);
    pushup(root, l, r);
  }
}

void print(int root, int l, int r){
    printf("%d %dn", root, mm[root]);
    if(l < r){
      int mid = (l r)/2;
      print(2*root, l, mid);
      print(2*root 1, mid 1, r);
    }
}

int main(){
  int w, n, m;
  scanf("%d%d%d", &n, &m, &w);
  for(int i = 1; i <= n; i )
    scanf("%d", &a[i]);
  memset(setv, 0, sizeof(setv));
  build(1, 1, n);
//  print(1, 1, n);
  for(int i = 1; i <= m; i ){
    minn = inf;
    query(1, 1, n, mm[1]);
    //cout << minn << endl;
    if(n-minn 1 < w) modify(1, 1, n, n-w 1, n, 1);
    else modify(1, 1, n, minn, minn w-1, 1);
  }
  printf("%I64dn", mm[1]);
  return 0;
}
```
昨晚上面两题时间还有15分钟左右,后两题没想出什么好办法。下次再补上。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

This article teaches you how to use ChatGPT to quickly write a report This article teaches you how to use ChatGPT to quickly write a report May 14, 2023 pm 04:04 PM

This article will share the entire process of training ChatGPT (the latest GPT-4 model version) and generating reports, and discuss the common problems that exist in the use of ChatGPT, and how to use ChatGPT to maximize learning and work efficiency. The following is the entire process of generating an AI safety report. Infrastructure topic selection A high-quality topic selection can help academic researchers quickly determine the entry point of the report, guide readers to capture the main theme of the report, and make the entire report present a clearer structure and logic. By introducing the background of the report or providing keywords and overview to ChatGPT, ChatGPT can generate topic selections in a few seconds for researchers' reference. When we ask questions, we can ask ChatGPT to generate multiple topic choices at the same time, which helps

MySQL vs. Oracle: Analysis and Reporting Support Comparison MySQL vs. Oracle: Analysis and Reporting Support Comparison Jul 12, 2023 pm 07:37 PM

MySQL and Oracle: Comparison of Support for Analysis and Reporting Functions In the modern data-driven world, as enterprise data continues to grow, the demand for data analysis and reporting functions is also increasing. As the two most popular relational database management systems (RDBMS), MySQL and Oracle have high support performance in this regard. This article will compare them in terms of their support for data analysis and reporting functions, and demonstrate the differences through code examples. First, let’s take a look at MySQL’s data analysis

The 'emergence' moment of artificial intelligence: How do data centers solve problems? The 'emergence' moment of artificial intelligence: How do data centers solve problems? Nov 23, 2023 pm 12:30 PM

When hundreds of industry-oriented AI large models appear, the data center hosting the large models is quietly changing. Large models require large computing power. On the one hand, data centers will provide diverse computing comprehensive capabilities as the computing power base for digital transformation to meet the intelligent needs of different industries; on the other hand, data centers continue to improve energy use efficiency, which requires A better computing architecture and lower energy consumption generate greater computing power, which not only achieves green and low carbon itself, but also empowers the intelligent transformation of other industries and promotes the carbon reduction of the whole society. According to data from the Ministry of Industry and Information Technology, the total number of data center racks in use in my country will exceed 5.9 million standard racks in 2022, the number of servers will be approximately 20 million, and the average annual growth rate of data center storage capacity will exceed 50%. At the same time, throughout the

Java development: How to do code coverage testing and reporting Java development: How to do code coverage testing and reporting Sep 21, 2023 pm 12:42 PM

Java Development: How to Conduct Code Coverage Testing and Reporting In Java development, code coverage testing is an important tool that can help us determine whether test cases cover various parts of the code, and understand the testing quality of the code. This article describes how to conduct code coverage testing and generate corresponding reports, and provides some specific code examples. Code coverage testing measures the coverage of each part of the code by running test cases and collecting execution information. In Java development, commonly used code coverage testing tools

How to read Kuaishou's 2023 annual report How to read Kuaishou's 2023 annual report Feb 23, 2024 pm 12:34 PM

Kuaishou releases an annual report for everyone to read every year, so what do you think of this year’s annual report? Users can search for annual memories in the search bar. This introduction to the 2023 annual report viewing method can tell you how to operate it. The following is a detailed introduction, come and take a look! Kuaishou usage tutorial: Where can I exchange Kuaishou coins for Kuaishou Express version? Answer: Search for annual memories in the search bar. Specific introduction: 1. First click on the search bar above, enter annual memories, and then click to participate. 2. After entering, click Open Now below. 3. Swipe down to turn pages. 4. At the end, you can have the function of publishing works with one click to share them.

Machine learning: 73% of enterprises are lost in survival Machine learning: 73% of enterprises are lost in survival Apr 11, 2023 pm 09:07 PM

As we all know, machine learning (ML) is one of the key technologies of artificial intelligence and an application technology that is gradually becoming mature. Specifically, this technology can bring changes to future data science, allowing application companies to make driven decisions based on more data analysis, thereby improving users' business experience. So, in what aspects and to what extent does ML currently improve the business operations of enterprises? Recently, Forrester Consulting based on a survey of 150 company data leaders and decision-makers in North America, and concluded some important performances of ML in business operation decisions. Which of these survey conclusions can help us and learn from us? Let’s look at some key information first. What machine learning affects

Six business intelligence challenges IT teams must address Six business intelligence challenges IT teams must address Apr 02, 2024 am 11:52 AM

Business intelligence (BI) enables businesses to derive insights from large amounts of data. But doing so requires overcoming a number of strategic and tactical challenges. Currently, organizations of all types are inundated with data from a variety of sources, and trying to make sense of it all is overwhelming. Therefore, a strong business intelligence (BI) strategy can help organize processes and ensure business users are able to access and act on business insights. Through BI strategies, various data sources can be integrated to provide users with accurate and useful information. The benefits of a BI strategy are many. First, it helps organizations better understand their business data and provide deep insights. Second, a BI strategy can also help organizations manage and analyze large amounts of data, according to Seattle-based Launch Consulting Group

MySQL vs. Oracle: Performance comparison for real-time data analysis and reporting MySQL vs. Oracle: Performance comparison for real-time data analysis and reporting Jul 13, 2023 pm 02:33 PM

MySQL vs. Oracle: Performance Comparison for Real-Time Data Analysis and Reporting Introduction: In modern data-driven decision-making environments, real-time data analysis and reporting have become critical. Database systems are one of the core components of data analysis and reporting. MySQL and Oracle are two widely used relational database management systems. This article will compare their performance in real-time data analysis and reporting, and illustrate it through code examples. Background: MySQL is an open source relational database management system widely used in We

See all articles