ZOJ 3212: K-Nice

K-Nice

///@author Sycamore, ZJNU
///@date 2017-02-09 
#include<iostream>
#include<algorithm>
using namespace std;
int mat[15][15];
int main()
{
	int T, M, N, k;
	cin >> T;
	while (T--)
	{
		cin >> N >> M >> k;
		fill(*(mat + 1), *(mat + 15) + 15, 1);
		if (k == 0)
		{
			for (int i = 0; i<N; i++)
				for (int j = 0; j < M; j++)
				{
					cout << 1 << (j == M - 1 ? ‘\n‘ : ‘ ‘);
				}
			continue;
		}
		if (k % (M - 2) == 0)fill(*(mat + 1), *(mat + k / (M - 2) + 1) + 15, 0);
		else {
			fill(*(mat + 1), *(mat + k / (M - 2) + 1) + 15, 0);
			for (int i = 0; i <= k % (M - 2); i++)
			{
				mat[k / (M - 2) + 2][i] = 0;
			}
		}
		for (int i = 0; i<N; i++)
			for (int j = 0; j < M; j++)
			{
				cout << mat[i][j] << (j == M - 1 ? ‘\n‘ : ‘ ‘);
			}
	}
	return 0;
}

pasting

时间: 2024-10-07 11:14:11

ZOJ 3212: K-Nice的相关文章

ZOJ 3212 K-Nice (K)

K-Nice Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this on

zoj 3715 K - Kindergarten Election

一个班有n个小朋友,要选一个班长,(n>=3),每个人不能投自己,给出每个人想要选的人,1号小朋友相当班长,如果一个小朋友不选自己 那么,自己可以给他bi个糖果让他选自己,那么请输出,最少花费多少个糖果 ,1号小朋友可以当上班长 开始的做法是贪心小的,那么问题很复杂,直接枚举小的是不符合条件的 后来想,枚举一号小朋友最后的票为k,那么其他人的票肯定小于等于k-1,如果有小朋友的选票高于k-1,那么先把投这个人的所有小朋友贿赂到小于k-1,按照需要的糖果数量 如果这个时候的选票大于k了,那么显然这

zoj 3212 K-Nice(构造)

K-Nice Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this on

ZOJ 3599 K倍动态减法游戏

下面的文字辅助理解来自http://blog.csdn.net/tbl_123/article/details/24884861 博弈论中的 K倍动态减法游戏,难度较大,参看了好多资料才懵懂! 此题可以看作 Fibonacci 博弈的扩展,建议没弄懂 Fibonacci博弈的先学那个,个人整理 http://blog.csdn.net/tbl_123/article/details/24033245 : 而说扩展体现在数列不再是Fib数列,是根据 k 的值自行构造的,其它换汤不换药,具体构造方法

融合后如何如何后如何如何

http://ypk.39.net/search/all?k=%A6%C6%B6%F5%D6%DD%C4%C4%C0%EF%C2%F2%C3%C0%C9%B3%CD%AAQ%A3%BA%A3%B8%A3%B6%A3%B3%A3%B9%A3%B0%A3%B2%A3%B9%A3%B6%A3%B2%A1%C6 http://ypk.39.net/search/all?k=%A8z%BE%A3%C3%C5%C4%C4%C0%EF%C2%F2%C3%C0%C9%B3%CD%AAQ%A3%BA%A3%B8%

哥哥ukulele

http://ypk.39.net/search/all?k=%A1%FB%C6%CE%CC%EF%C4%C4%C0%EF%D3%D0%B0%B2%C0%D6%CB%C0%D2%A9%C2%F4Q%A3%BA%A3%B8%A3%B6%A3%B3%A3%B9%A3%B0%A3%B2%A3%B9%A3%B6%A3%B2%A1%BC http://ypk.39.net/search/all?k=%A1%D3%B8%A3%C7%E5%C4%C4%C0%EF%D3%D0%B0%B2%C0%D6%CB%C0

ZOJ 2112 Dynamic Rankings(带修改的区间第K大,分块+二分搜索+二分答案)

Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They

zoj 2112 Dynamic Rankings(主席树&amp;动态第k大)

Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with the query like to simply find the k-th smallest number of the given N numbers. They

zoj 3635 Cinema in Akiba (树状数组求第K大)

Cinema in Akiba Cinema in Akiba (CIA) is a small but very popular cinema in Akihabara. Every night the cinema is full of people. The layout of CIA is very interesting, as there is only one row so that every audience can enjoy the wonderful movies wit