这套题有史以来做的最恶心的一套题,没有之一;
A题,讲的不明不白的。到底是区间还是这4个数,没有说明白, 交了7遍 全都是WA on test 4;因为一直认为就是这4个数里面选择 ,恶心, 实际要求是在区间里选定某个值;
暴力枚举!!!!!!!
A:
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car.
Masha came to test these cars. She could climb into all cars, but she liked only the smallest car.
It's known that a character with size a can climb into some car with size b if and only if a ≤ b, he or she likes it if and only if he can climb into this car and 2a ≥ b.
You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.
You are given four integers V1, V2, V3, Vm(1 ≤ Vi ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3.
Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively.
If there are multiple possible solutions, print any.
If there is no solution, print "-1" (without quotes).
50 30 10 10
50 30 10
100 50 10 21
-1
In first test case all conditions for cars' sizes are satisfied.
In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.
【题意】
公熊,母熊,小熊,玛莎,
A喜欢B的 条件是, ab
玛莎只喜欢最小的 这是一个限定条件;暴力枚举!!!
【代码实现】
#include
#include
#include
#include
using namespace std;
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
int x,y,z,q;
int flag=1;
for(int i=1;i<=200;i++){
for(int j=1;j=i && b<=j && 2*b>=j && c<=k && 2*c>=k && d<=k && 2*d>=k && 2*d
B题要比A题简单, 就是题干又臭又长,
B:
给定九宫格, 输入x,y坐标 确定 x,y 在 小九宫格的哪个位置上, 对应大九宫格的位置全部赋值为!
若没有 。 则 全部都赋值为 !
【思路方法】
先找到,x,y坐标对应小九宫格的位置里 是不是有。 没有。 就全部 赋值! 有的话 对应大九宫格位置 赋值!
【代码实现】
#include
#include
#include
#include
using namespace std;
int main()
{
char str[100][100];
for(int i=0;i<9;i++)
for(int j=0;j<9;j++)
cin>>str[i][j];
int x,y;
cin>>x>>y;
x--,y--;
x%=3;
y%=3;
x*=3;
y*=3;
int flag=0;
for(int i=x;i
C
Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly.
Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.
The first line contains a single integer n (1 ≤ n ≤ 105) — the number of actions Valentin did.
The next n lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types:
- Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and w is the word that Valentin said.
- Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and w is the word that Valentin said.
- Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and s is the guess — a lowercase English letter.
All words consist only of lowercase English letters. The total length of all words does not exceed 105.
It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.
Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.
5 ! abc . ad . b ! cd ? c
1
8 ! hello ! codeforces ? c . o ? d ? h . l ? e
2
7 ! ababahalamaha ? a ? b ? a ? b ? a ? h
0
In the first test case after the first action it becomes clear that the selected letter is one of the following: a, b, c. After the second action we can note that the selected letter is not a. Valentin tells word "b" and doesn't get a shock. After that it is clear that the selected letter is c, but Valentin pronounces the word cd and gets an excessive electric shock.
In the second test case after the first two electric shocks we understand that the selected letter is e or o. Valentin tries some words consisting of these letters and after the second word it's clear that the selected letter is e, but Valentin makes 3 more actions before he makes a correct hypothesis.
In the third example the selected letter can be uniquely determined only when Valentin guesses it, so he didn't get excessive electric shocks.
【题意】
给定 n种 串; 形式为 '!' '.' '?" 这三种分别代表 '!' 受罚 '.'不受罚 '?' 猜答案
n行, 每一串字符,
? 猜字母是不是这个字母,
! 这串字母里有这个字母
。 串里面没有这个字母
最后一次之前 每一个 ? 和 ! 都会被罚一次;
然后问 可以避免受罚的 次数是多少, 就是第几次是已经确认找到这个字母后没有必要的操作 是多少次。
【思路】
模拟
最后一次之前;
! 当前串和 可能 字母取交集
。 当前串和可能字母取 差集
? 当前字母 和可能字母 取 差
pos 记录可能字母。
【代码实现】
#include
#include
#include
#include
#define SHUT std::ios::sync_with_stdio(false)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int v[50];
int f[50];
int main()
{
SHUT;
int n;
for(int i = 0; i < 26; i++) v[i] = 1;
string str,temp;
cin>>n;
int ans=0;
int pos=26;
for(int i=1;i<=n;i++)
{
char c;
cin>>c;
if(c=='?')
{
char y;
cin>>y;
if(i!=n)
{
if(pos==1)
ans++;
if(v[y-'a']==1)
pos--;
v[y-'a']=0;
}
}
else
{
if(c=='!'&&pos==1)
ans++;
cin>>str;
mem(f,0);
int len=str.length();
for(int j=0;j