Codeforces 758C- Unfair Poll
来源:互联网 发布:一个简单的php程序 编辑:程序博客网 时间:2024/06/02 00:26
C. Unfair Polltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.Seating in the class looks like a rectangle, where n rows with m pupils in each.The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order of their seating, then she continues to ask pupils from the next row. If the teacher asked the last row, then the direction of the poll changes, it means that she asks the previous row. The order of asking the rows looks as follows: the 1-st row, the 2-nd row, ..., the n - 1-st row, the n-th row, the n - 1-st row, ..., the 2-nd row, the 1-st row, the 2-nd row, ...The order of asking of pupils on the same row is always the same: the 1-st pupil, the 2-nd pupil, ..., the m-th pupil.During the lesson the teacher managed to ask exactly k questions from pupils in order described above. Sergei seats on the x-th row, on the y-th place in the row. Sergei decided to prove to the teacher that pupils are asked irregularly, help him count three values: the maximum number of questions a particular pupil is asked, the minimum number of questions a particular pupil is asked, how many times the teacher asked Sergei.If there is only one row in the class, then the teacher always asks children from this row.InputThe first and the only line contains five integers n, m, k, x and y (1 ≤ n, m ≤ 100, 1 ≤ k ≤ 1018, 1 ≤ x ≤ n, 1 ≤ y ≤ m).OutputPrint three integers: the maximum number of questions a particular pupil is asked, the minimum number of questions a particular pupil is asked, how many times the teacher asked Sergei.Examplesinput1 3 8 1 1output3 2 3input4 2 9 4 2output2 1 1input5 5 25 4 3output1 1 1input100 100 1000000000000000000 100 100output101010101010101 50505050505051 50505050505051NoteThe order of asking pupils in the first test: the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; the pupil from the first row who seats at the third table; the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table; the pupil from the first row who seats at the third table; the pupil from the first row who seats at the first table, it means it is Sergei; the pupil from the first row who seats at the second table;The order of asking pupils in the second test: the pupil from the first row who seats at the first table; the pupil from the first row who seats at the second table; the pupil from the second row who seats at the first table; the pupil from the second row who seats at the second table; the pupil from the third row who seats at the first table; the pupil from the third row who seats at the second table; the pupil from the fourth row who seats at the first table; the pupil from the fourth row who seats at the second table, it means it is Sergei; the pupil from the third row who seats at the first table;题目大意:有n行m列学生,有一位老师在课上会问k个问题,在行上,是按照1,2。。。。n-1,n,n-1.。。。1这样的顺序提问,求学生当中回答问题个数最多和最少的个数,以及在第x行第y位的同学回答的问题数。
要学习别人的代码.
#include<bits/stdc++.h>using namespace std;#define LL long long#define MP(a,b) make_pair(a,b)#define mem(a,b) memset(a,b,sizeof(a))#define REP(i,a,b) for(int i=a;i<=b;++i)#define FOR(i,a,b) for(int i=a;i<b;++i)#define pii pair<int,int>#define sf scanf#define pf printfconst int maxn = 100;int n, m, xx, yy;LL kk, mmp[maxn+5][maxn+5];int main(){ sf("%d%d%lld%d%d", &n, &m, &kk, &xx, &yy); LL a, b, c, ans1, ans2, ans3; int type; if(n == 1) { ans1 = ans2 = kk/m, b = kk%m; if(b) ++ans1; ans3 = (yy<=b) ? ans1 : ans2; pf("%lld %lld %lld\n", ans1, ans2, ans3); return 0; } a = (n-1)*m*2; b = kk/a, c = kk%a; mem(mmp, 0); REP(i,1,n-1) REP(k,1,m)//这个学 mmp[i][k] += b;//都直接放到这里面就不怕了.不会犯特例的错 REP(i,2,n) REP(k,1,m) mmp[i][k] += b; int ti = 1, tk = 1; while(ti<n && c) { ++mmp[ti][tk], ++tk, --c; if(tk==m+1) ++ti, tk = 1; } while(ti>=1 && c) { ++mmp[ti][tk], ++tk, --c; if(tk==m+1) --ti, tk = 1; } LL mx = 0, mm = 1e18; REP(i,1,n) REP(k,1,m) { mx = max(mx, mmp[i][k]); mm = min(mm, mmp[i][k]); } pf("%lld %lld %lld\n", mx, mm, mmp[xx][yy]); return 0;}
阅读全文
0 0
- 【codeforces 758C】Unfair Poll
- Codeforces 758C-Unfair Poll
- Codeforces 758C Unfair Poll
- Codeforces 758C- Unfair Poll
- Codeforces 758C Unfair Poll 暴力模拟
- codeforces 758C - Unfair Poll 细节题
- Codeforces 758C Unfair Poll 【数学】【思维】
- 【Codeforces 758 C Unfair Poll】+ 细节
- CodeForces 758C Unfair Poll(模拟)
- 758C - Unfair Poll
- Codeforces Round #392 (Div. 2) 758C Unfair Poll
- Codeforces 758C Unfair Poll 数学推导,公式
- Unfair Poll CodeForces
- Codeforces Round #392 (Div. 2) C - Unfair Poll codeforces
- Unfair Poll codeforce758 C
- Codeforces Round #392 (Div. 2) C && 758C Unfair Poll(模拟)
- Codeforces Round #392 (Div. 2) C. Unfair Poll
- Codeforces Round #392 (Div. 2)-C. Unfair Poll(xjb)
- java作用域
- 设计模式_ 代理模式(11)
- 9月第二周
- Maven学习笔记(四)-----生命周期|POM常用元素介绍
- hihoCoder1403(后缀数组 + 二分)
- Codeforces 758C- Unfair Poll
- 微信公众号开发(十二)OAuth2.0网页授权
- 顺序表Test1
- linux fork创建子进程
- 红烧肉(HSR)挖矿教程
- 【C/C++开发】容器set和multiset,C++11对vector成员函数的扩展(cbegin()、cend()、crbegin()、crend()、emplace()、data())
- OpenJudge百炼-2747-数字方格-C语言-枚举
- C#修改项目名称(Solution)
- 小白的程序员自学之路