/* 题意:给你一个n*n的格子,每一个格子都有一个数值!将两只bishops放在某一个格子上, 每一个bishop可以攻击对角线上的格子(主对角线和者斜对角线),然后会获得格子上的 数值(只能获取一次).要求输出两个bishops获取的最大值以及它们所在的位置! 思路:直接暴力!....不错的暴力题目! 首先我们都知道每一条主对角线上的横纵坐标的和相同,每一条副对角线上的横纵坐标的差相同! 那么我们在输入的时候就可以将所有对角线上的数值之和求出来了! 最后我们发现如果要获得最大值,那么还有一条…
CodeForces463C Gargari and Bishops(贪心) CodeForces463C 题目大意:  在国际象棋的棋盘上放两个主教,这个两个主教不能攻击到同一个格子,最后的得分是这两个主教的攻击的格子上的分数之和. 求最大的分数. 解题思路:  由于攻击的范围是对角线,所以两个主教一个在黑格,一个在白格.画个图就能够发现一旦一个主教放在了黑格.那么剩下的黑格是都不能在放主教的,否则就是攻击到同样的格子. 所以求出每条对角线的和,通过这个得出每一个格子作为主教的得分,最后黑白格…
很简单的暴力枚举,却卡了我那么长时间,可见我的基本功不够扎实. 两个数相乘等于一个数6*n,那么我枚举其中一个乘数就行了,而且枚举到sqrt(6*n)就行了,这个是暴力法解题中很常用的性质. 这道题找出a和b中最小的那个,然后开始枚举,一直枚举到sqrt(6*n)的向上取整.这样所有可能是答案的情况都有啦.再干别的都是重复的或者肯定不是最小面积的. #include<iostream> #include<cstdio> #include<cstdlib> #includ…
称号: 意甲冠军:给定一个矩阵,每格我们有一个数,然后把两个大象,我希望能够吃的对角线上的所有数字.我问两个最大的大象可以吃值. 分析:这种想法是暴力的主题,计算出每一格放象的话能得到多少钱,然后求出两个不冲突的最大值.我比赛的时候写的方法是先求出每个值,编号之后存到数组里面,然后在通过一系列处理得到,总之非常麻烦.写了一个多小时.最后才发现有一点小错误,没时间了.初始例子也没有通过. 然后看了下别人写的,太简洁了.直接用行和列和和差就能够直接求出来.看来代码能力还很有待提高啊. 我的AC代码:…
题目出处: http://codeforces.com/contest/463/problem/C 感觉本题还是挺难的.须要好好总结一下. 计算对角线的公式: 1 右斜对角线,也叫主对角线的下标计算公式: int index = j-i; 可是为了不使用绝对值,而且分开j = 2, i = 1和j = 1, i = 2的情况,那么公式变为: j-i+n,正方形n为行数或列数 2 左对角线.也叫第二对角线: int index = i+j; 例如以下图计算右斜对角线: 这样计算下标.是为了方便计算…
题目链接:http://codeforces.com/contest/463/problem/C 题目意思:要在一个 n * n 大小的棋盘上放置两个bishop,bishop可以攻击的所有位置是包括经过bishop 位置的两条成90度的对角线所经过的所有坐标点.每个坐标点都有数字在上面,放置一个bishop后,可以获得能被放置的bishop攻击的所有坐标点的数字的和.但是有一个条件限制:同一个坐标点不能被两个bishop攻击,也就是四条对角线的交点不能是棋盘上的某个坐标点.求出在该条件限制下,…
http://codeforces.com/contest/463/problem/C 在一个n∗n的国际象棋的棋盘上放两个主教,要求不能有位置同时被两个主教攻击到,然后被一个主教攻击到的位置上获得得分.求得分的最大值. 黑白格分开考虑最大值即可,注意全0情况. #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #i…
题目链接 这个题, 最主要的应该是找到对角线上的格子的关系. “ \" 这种对角线, 关系是x-y+n相等, ” / “ 这种, 关系是x+y相等.知道每个格子的两种对角线的值, 那么这个格子的值可以表示为d1[x+y]+d2[x-y+n]-a[x][y], a[x][y]是初值. 知道这个以后就好做了. 具体可以看这里http://blog.csdn.net/kenden23/article/details/38959141..... #include<bits/stdc++.h>…
依据贪心能够知道,放置的教主必须不能相互攻击到(也就是不在一条对角线上)才干够使得结果最大化. 依据观察能够得到教主相互不攻击的条件是他的坐标和互为奇偶(x + y) 之后直接暴力,处理每一个坐标对角线的和就好 时间复杂度 0(n ^ 2) #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; const int maxn = 2…
http://codeforces.com/problemset/problem/778/A 题意:给出字符串s和字符串p,还有n个位置,每一个位置代表删除s串中的第i个字符,问最多可以删除多少个字符使得s串依旧包含p串. 思路:想到二分,以为二分做法依旧很暴力.但是别人的做法确实就是二分暴力搞啊. 枚举删除字符数,然后判断的时候如果s串包含p串,那么可以往右区间找,否则左区间找. #include <bits/stdc++.h> using namespace std; #define N…
http://codeforces.com/problemset/problem/733/C 题意:给出一个序列的怪兽体积 ai,怪兽只能吃相邻的怪兽,并且只有体积严格大于相邻的怪兽才能吃,吃完之后,这只怪兽的体积会变成原体积 + 吃的怪兽的体积,接下来给出 k 个怪兽的体积 bi,问能不能满足经过一系列操作后让剩下的怪兽体积变得满足下面的序列. 思路:昨晚想的时候觉得好复杂,今天补题发现实际上只有一种情况,就是每一个区间里的怪兽体积对应于一个 bi,然后拆成 k 个区间,分别找区间里面最大的去…
There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles of Coral Park City) consist of several beautiful islands. The citizens requested construction of bridges between islands to resolve inconveniences of u…
E. Holes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/13/problem/E Description Little Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules: There are…
B. ZgukistringZ Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/B Description Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one. GukiZ has strings a,…
A. Robot Bicorn Attack Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/175/problem/A Description Vasya plays Robot Bicorn Attack. The game consists of three rounds. For each one a non-negative integer amount of points is gi…
A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/A Description Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess». Thi…
I. Sale in GameStore Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/I Description A well-known Berland online games store has announced a great sale! Buy any game today, and you can download more games for free!…
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:…
E. Vasya and Good Sequences time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has a sequence $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$. Vasya may pefrom the fol…
B. DZY Loves FFT 题目连接: http://codeforces.com/contest/444/problem/B Description DZY loves Fast Fourier Transformation, and he enjoys using it. Fast Fourier Transformation is an algorithm used to calculate convolution. Specifically, if a, b and c are s…
F. Xors on Segments 题目连接: http://www.codeforces.com/contest/620/problem/F Description You are given an array with n integers ai and m queries. Each query is described by two integers (lj, rj). Let's define the function . The function is defined for o…
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-european-regional-contest-neerc-08-en.pdf 此题题意是给你一个单对单密文,让你还原为原文,原文有个性质是,每个单词都是元音和辅音交替组成. 做法是直接5重for,暴力枚举AEIOU分别对应的字母,然后检查,然后输出 详见代码: //#include<iostream>…
http://codeforces.com/problemset/problem/755/A 题意:给出一个n,让你找一个m使得n*m+1不是素数. 思路:暴力枚举m判断即可. #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <string> #include <iostr…
A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nic…
A. Bus to Udayland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The…
B. Dinner with Emma 题目连接: http://www.codeforces.com/contest/616/problem/A Description Jack decides to invite Emma out for a dinner. Jack is a modest student, he doesn't want to go to an expensive restaurant. Emma is a girl with high taste, she prefer…
B. Ants Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/317/problem/B Description It has been noted that if some ants are put in the junctions of the graphene integer lattice then they will act in the following fashion: eve…
这个题是个想法题 先预处理连通块,然后需要用到一种巧妙暴力,即0变1,1变0,一列列添加删除 复杂度O(n^3) #include <cstdio> #include <iostream> #include <ctime> #include <vector> #include <cmath> #include <map> #include <queue> #include <algorithm> #includ…
A. 2Char Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/A Description Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinc…
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The new cottage settlement is organized near the capital of Flatland. The construction company that is building the sett…