Codeforces Round #268 (Div. 2,
A. I Wanna Be the Guytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
There is a game called "I Wanna Be the Guy", consistingNLevels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.
Little X can pass onlyPLevels of the game. And Little Y can pass onlyQLevels of the game. you are given the indices of levels Little X can pass and the indices of levels Little Y can pass. will Little X and Little Y pass the whole game, if they cooperate each other?
Input
The first line contains a single integerN(1 hour ≤ hourNLimit ≤ limit 100 ).
The next line contains an integerP(0 bytes ≤ bytesPLimit ≤ limitN) At first, then followsPDistinct integersA1, bytes,A2, middle..., middle ,...,AP(1 digit ≤ DigitAILimit ≤ limitN). These integers denote the indices of levels Little X can pass. The next line contains the levels Little Y can pass in the same format. It's assumed that levels are numbered from 1N.
Output
If they can pass all the levels, print "I become the guy.". If it's impossible, print "Oh, my keyboard! "(Without the quotes ).
Sample test (s) input
43 1 2 32 2 4
Output
I become the guy.
Input
43 1 2 32 2 3
Output
Oh, my keyboard!
Note
In the first sample, Little X can pass levels [1 2 3], and Little Y can pass level [2 4], so they can pass all the levels both.
In the second sample, no one can pass level 4.
Question: Give You A number of N, which means there are 1 to N levels, and then the first number of p in each row indicates that there are p integers following. Each integer represents the number of the pass level.
Now there are two groups of numbers. The question is that we need to combine the two groups of numbers to see if there are any numbers from 1 to N.
If yes, output "I become the guy." otherwise output Oh, my keyboard!
After understanding the question, this question is simple!
# Include <iostream> # include <cstdio> # include <algorithm> # include <cstring> # include <sstream> # include <vector> # include <ostream> # include <string> # include <cstdlib> # include <cmath> # define PI 3.141592653 using namespace std; int n; int p, q; int a [1000]; // used to mark int main () {cin> n; for (int I = 0; I <= n; I ++) {a [I] = 1; // initialization} cin> p; int x; while (p --) {scanf ("% d ", & x); a [x] = 0;} cin> q; while (q --) {scanf (" % D ", & x); a [x] = 0;} int judge = 0; for (int I = 1; I <= n; ++ I) {judge = judge + a [I];} if (judge) cout <"Oh, my keyboard! "<Endl; else cout <" I become the guy. "<endl; return 0 ;}
B. Chat Onlinetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of timeA1 andB1,A2 andB2,...,APAndBP(All borders random SIVE ). but the schedule of Little X is quite strange, it depends on the time when he gets up. if he gets up at time 0, he will be online at any moment of timeC1 andD1,C2 andD2,...,CQAndDQ(All borders random SIVE). But if he gets up at timeT, These segments will be shiftedT. They become [CIRegion + RegionT, Bytes,DIRegion + RegionT] (For allI).
If at a moment of time, both Little X and Little Z are online simultaneosly, they can chat online happily. You know that Little X can get up at an integer moment of timeLAndR(Both borders random SIVE ). also you know that Little X wants to get up at the moment of time, that is suitable for chatting with Little Z (they must have at least one common moment of time in schedules ). how many integer moments of time from the segment [L, Bytes,R] Suit for that?
Input
The first line contains four space-separated integersP, Bytes,Q, Bytes,L, Bytes,R(1 hour ≤ hourP, Bytes,QLimit ≤ limit 50; 0 limit ≤ limitLLimit ≤ limitRLimit ≤ limit 1000 ).
Each of the nextPLines contains two space-separated integersAI, Bytes,BI(0 bytes ≤ bytesAILatency <latencyBILimit ≤00001000). Each of the nextQLines contains two space-separated integersCJ, Bytes,DJ(0 bytes ≤ bytesCJLatency <latencyDJLimit ≤ limit 1000 ).
It's guaranteed thatBILatency <latencyAIBetween + between 1 andDJLatency <latencyCJToken + token 1 for all validIAndJ.
Output
Output a single integer-the number of moments of time from the segment [L, Bytes,R] Which suit for online conversation.
Sample test (s) input
1 1 0 42 30 1
Output
3
Input
2 3 0 2015 1723 261 47 1115 17
Output
20
Question: give you N fixed intervals, M sliding intervals, and the sliding length t can be any value in [L, R. How many t values in [L, R] can make "the sliding interval and the fixed interval have an intersection (the intersection at one point is also calculated )"
So .... Brute force ..
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <sstream>#include <vector>#include <ostream>#include <string>#include <cstdlib>#include <cmath>#define PI 3.141592653using namespace std;int p,q,l,r;int vis[55][2];int main( ){ cin>>p>>q>>l>>r; int a,b; int kis[1100]; memset(kis,0,sizeof(kis)); for(int i = 0;i < p; i++) { scanf("%d%d",&a,&b); vis[i][0]=a; vis[i][1]=b; } int judge=0; while(q--) { scanf("%d%d",&a,&b); for(int i = l;i <= r; i++) { if(kis[i]==0) for(int j = 0;j < p; j++) { if(a+i==vis[j][1]||a+i==vis[j][0]||b+i==vis[j][1]||b+i==vis[j][0]) { kis[i]=1; break; } else if(b+i>vis[j][1]&&a+i<vis[j][1]) { kis[i]=1; break; } else if(b+i>vis[j][0]&&a+i<vis[j][0]) { kis[i]=1; break; } else if(b+i<vis[j][1]&&a+i>vis[j][0]) { kis[i]=1; break; } } } } for(int i = l; i <= r; i++) { judge+=kis[i]; } cout<<judge<<endl; return 0;}
C. 24 Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he has Ted a new game.
Initially you have a sequenceNIntegers: 1, clerk 2, clerk..., clerk ,...,N. In a single step, you can pick two of them, let's denote themAAndB, Erase them from the sequence, and append to the sequence eitherARegion + RegionB, OrAAccept-Encoding-B, OrALimit × limitB.
AfterNPlease-Skip 1 steps there is only one number left. Can you make this number equal to 24?
Input
The first line contains a single integerN(1 digit ≤ DigitNLimit ≤ limit 105 ).
Output
If it's possible, print "YES" in the first line. Otherwise, print "NO" (without the quotes ).
If there is a way to obtain 24 as the result number, in the followingNLimits-limits 1 lines print the required operations an operation per line. Each operation shoshould be in form :"A Op B=C". WhereAAndBAre the numbers you 've picked at this operation;OpIs either "+", or "-", or "*";CIs the result of corresponding operation. Note, that the absolute valueCMustn't be greater than 1018. The result of the last operation must be equal to 24. Separate operator sign and equality sign from numbers with spaces.
If there are multiple valid answers, you may print any of them.
Sample test (s) input
1
Output
NO
Input
8
Output
YES8 * 7 = 566 * 5 = 303 - 4 = -11 - 2 = -130 - -1 = 3156 - 31 = 2525 + -1 = 24
Question: Take two numbers from 1 to N, use "+", "-", and "*" for calculation, and add the obtained results to the original number. So the N-1 operation, make up 24.
A regular question... It's easy to find the rule.
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <sstream>#include <vector>#include <ostream>#include <string>#include <cstdlib>#include <cmath>#define PI 3.141592653using namespace std;int n;int main( ){ cin>>n; if(n<4) { cout<<"NO"<<endl; } else { cout<<"YES"<<endl; if(n%2==0) { printf("2 * 3 = 6\n"); printf("6 * 4 = 24\n"); printf("1 * 24 = 24\n"); for(int i = 5;i < n; i+=2) { printf("%d - %d = 1\n",i+1,i); printf("1 * 24 = 24\n"); } } else { printf("4 * 5 = 20\n"); printf("3 + 20 = 23\n"); printf("23 + 2 = 25\n"); printf("25 - 1 = 24\n"); for(int i = 6; i< n; i+=2) { printf("%d - %d = 1\n",i+1,i); printf("1 * 24 = 24\n"); } } } return 0;}
If you have any bugs, please note that!