CF758 C. Unfair Poll (模拟)
来源:互联网 发布:淘宝促销管理在哪里 编辑:程序博客网 时间:2024/06/16 00:36
传送门
题目大意:有n行m列学生,有一位老师在课上会问k个问题,在行上,是按照1,2。。。。n-1,n,n-1.。。。1这样的顺序提问,求学生当中回答问题个数最多和最少的个数,以及在第x行第y位的同学回答的问题数。
解题思路:不难发现,当n>1时,1,2,……,n-1,n,n-1,……3,2为一个循环节,即有2*n-2行,其中每个循环节第1行以及第n行都只回答一次,其他都回答了两次,然后直接用二维数组进行模拟即可。注意细节的地方。
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ *///#pragma comment(linker, "/STACK:102400000,102400000")#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <bitset>using namespace std;#define rep(i,a,b) for (int i=(a),_ed=(b);i<=_ed;i++)#define per(i,a,b) for (int i=(b),_ed=(a);i>=_ed;i--)#define pb push_back#define mp make_pairconst int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define LL long long#define ULL unsigned long long#define MS0(X) memset((X), 0, sizeof((X)))#define SelfType intSelfType Gcd(SelfType p,SelfType q){return q==0?p:Gcd(q,p%q);}SelfType Pow(SelfType p,SelfType q){SelfType ans=1;while(q){if(q&1)ans=ans*p;p=p*p;q>>=1;}return ans;}#define Sd(X) int (X); scanf("%d", &X)#define Sdd(X, Y) int X, Y; scanf("%d%d", &X, &Y)#define Sddd(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())#define all(a) a.begin(), a.end()#define mem(x,v) memset(x,v,sizeof(x))typedef pair<int, int> pii;typedef pair<long long, long long> pll;typedef vector<int> vi;typedef vector<long long> vll;inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}LL ans[105][105];int main(){//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);//ios::sync_with_stdio(0);//cin.tie(0);int n,m,x,y;LL k;scanf("%d%d%I64d%d%d",&n,&m,&k,&x,&y);int t;if(n>1) t = (2*n-2) * m;else t = m;for(int i=2;i<n;i++) { for(int j=1;j<=m;j++) { ans[i][j] = k/t*2; } } for(int j=1;j<=m;j++) { ans[1][j] = ans[n][j] = k/t; } int p = k % t; for(int i=1;i<=n && p;i++) { for(int j=1;j<=m && p;j++) { if(p) { ans[i][j]++; p--; } } } for(int i=n-1;i>1 && p;i--) { for(int j=1;j<=m && p;j++) { if(p) { ans[i][j]++; p--; } } } LL mx = 0, mi = inf_ll; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { mi = min(mi,ans[i][j]); mx = max(mx,ans[i][j]); } } printf("%I64d %I64d %I64d\n",mx,mi,ans[x][y]);return 0;}
0 0
- CF758 C. Unfair Poll (模拟)
- CodeForces 758C Unfair Poll(模拟)
- Codeforces 758C Unfair Poll 暴力模拟
- 758C - Unfair Poll
- Unfair Poll codeforce758 C
- Codeforces Round #392 (Div. 2) C && 758C Unfair Poll(模拟)
- 【codeforces 758C】Unfair Poll
- Codeforces 758C-Unfair Poll
- Codeforces 758C Unfair Poll
- Codeforces 758C- Unfair Poll
- Unfair Poll
- Unfair Poll
- codeforces 758C - Unfair Poll 细节题
- Codeforces 758C Unfair Poll 【数学】【思维】
- 【Codeforces 758 C Unfair Poll】+ 细节
- C. Unfair Poll-数数你会不会?
- CF758 B. Blown Garland (模拟)
- Codeforces Round #392 (Div. 2)C. Unfair Poll(找循环节)
- 【BZOJ】3884: 上帝与集合的正确用法
- nodejs 写爬虫爬取最近上映电影数据
- makefile中的all和.PHONY的作用
- [Leetcode] Reverse Integer
- HDU 1024 Max Sum Plus Plus【线性dp】
- CF758 C. Unfair Poll (模拟)
- js数组应用
- 欢迎使用CSDN-markdown编辑器
- makefile里PHONY的相关介绍
- CSDN的MarkDown图片大小的调整
- 用JS改变HTML图像和样式
- c/c++学生成绩管理系统
- 时间序列ARMA中p,q选择
- Eigen教程4 - 稀疏矩阵快速参考指南