Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.
As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such).
Brain took a lot of colourful pictures on colored and black-and-white film. Then he developed and translated it into a digital form. But now, color and black-and-white photos are in one folder, and to sort them, one needs to spend more than one hour!
As soon as Brain is a photographer not programmer now, he asks you to help him determine for a single photo whether it is colored or black-and-white.
Photo can be represented as a matrix sized n × m, and each element of the matrix stores a symbol indicating corresponding pixel color. There are only 6 colors:
'C' (cyan)'M' (magenta)'Y' (yellow)'W' (white)'G' (grey)'B' (black)The photo is considered black-and-white if it has only white, black and grey pixels in it. If there are any of cyan, magenta or yellow pixels in the photo then it is considered colored.
InputThe first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of photo pixel matrix rows and columns respectively.
Then n lines describing matrix rows follow. Each of them contains m space-separated characters describing colors of pixels in a row. Each character in the line is one of the 'C', 'M', 'Y', 'W', 'G' or 'B'.
OutputPrint the "#Black&White" (without quotes), if the photo is black-and-white and "#Color" (without quotes), if it is colored, in the only line.
Examples Input 2 2C MY Y Output #Color Input 3 2W WW WB B Output #Black&White Input 1 1W Output #Black&White题意:六种颜色; 如果有C' (cyan),'M' (magenta),'Y' (yellow)三种任意一种输出#Color; 否则输出#Black&White; #include<bits/stdc++.h> using namespace std; #define ll long long #define esp 0.00000000001 #define pi 4*atan(1) const int N=1e5+10,M=1e6+10,inf=1e9+10,mod=1e9+9; int main() { int x,y,z,i,t; scanf("%d%d",&x,&y); int ans=0; for(i=0;i<x;i++) { for(t=0;t<y;t++) { char a; cin>>a; if(a=='Y'||a=='M'||a=='C') ans=1; } } if(ans) printf("#Color\n"); else printf("#Black&White\n"); return 0; } B. Bakery time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputMasha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.
To bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only k storages, located in different cities numbered a1, a2, ..., ak.
Unforunately the law of the country Masha lives in prohibits opening bakery in any of the cities which has storage located in it. She can open it only in one of another n - k cities, and, of course, flour delivery should be paid — for every kilometer of path between storage and bakery Masha should pay 1 ruble.
Formally, Masha will pay x roubles, if she will open the bakery in some city b (ai ≠ b for every 1 ≤ i ≤ k) and choose a storage in some city s (s = aj for some 1 ≤ j ≤ k) and b and s are connected by some path of roads of summary length x (if there are more than one path, Masha is able to choose which of them should be used).
Masha is very thrifty and rational. She is interested in a city, where she can open her bakery (and choose one of k storages and one of the paths between city with bakery and city with storage) and pay minimum possible amount of rubles for flour delivery. Please help Masha find this amount.
InputThe first line of the input contains three integers n, m and k (1 ≤ n, m ≤ 105, 0 ≤ k ≤ n) — the number of cities in country Masha lives in, the number of roads between them and the number of flour storages respectively.
Then m lines follow. Each of them contains three integers u, v and l (1 ≤ u, v ≤ n, 1 ≤ l ≤ 109, u ≠ v) meaning that there is a road between cities u and v of length of l kilometers .
If k > 0, then the last line of the input contains k distinct integers a1, a2, ..., ak (1 ≤ ai ≤ n) — the number of cities having flour storage located in. If k = 0 then this line is not presented in the input.
OutputPrint the minimum possible amount of rubles Masha should pay for flour delivery in the only line.
If the bakery can not be opened (while satisfying conditions) in any of the n cities, print - 1 in the only line.
Examples Input 5 4 21 2 51 2 32 3 41 4 101 5 Output 3 Input 3 1 11 2 33 Output -1题意:给你n个点,m条边,k个货舱; 除了货舱就是商店,问某一个货舱到某一个商店的最短距离;思路:直接遍历一遍边即可; #include<bits/stdc++.h> using namespace std; #define ll long long #define esp 0.00000000001 #define pi 4*atan(1) const int N=1e5+10,M=1e6+10,inf=1e9+10,mod=1e9+9; int flag[N]; struct is { int u,v,w; }a[N]; int check(int x,int y) { if(flag[x]!=flag[y]) return 1; return 0; } int main() { int x,y,z,i,t; scanf("%d%d%d",&x,&y,&z); for(i=0;i<y;i++) scanf("%d%d%d",&a[i].u,&a[i].v,&a[i].w); for(i=0;i<z;i++) { scanf("%d",&t); flag[t]=1; } int ans=inf; for(i=0;i<y;i++) { if(check(a[i].u,a[i].v)) { ans=min(ans,a[i].w); } } if(ans==inf) printf("-1\n"); else printf("%d\n",ans); return 0; } C. Pythagorean Triples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputKatya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such that you can construct a right triangle with segments of lengths corresponding to triple. Such triples are called Pythagorean triples.
For example, triples (3, 4, 5), (5, 12, 13) and (6, 8, 10) are Pythagorean triples.
Here Katya wondered if she can specify the length of some side of right triangle and find any Pythagorean triple corresponding to such length? Note that the side which length is specified can be a cathetus as well as hypotenuse.
Katya had no problems with completing this task. Will you do the same?
InputThe only line of the input contains single integer n (1 ≤ n ≤ 109) — the length of some side of a right triangle.
OutputPrint two integers m and k (1 ≤ m, k ≤ 1018), such that n, m and k form a Pythagorean triple, in the only line.
In case if there is no any Pythagorean triple containing integer n, print - 1 in the only line. If there are many answers, print any of them.
Examples Input 3 Output 4 5 Input 6 Output 8 10 Input 1 Output -1 Input 17 Output 144 145 Input 67 Output 2244 2245题意:给出一直角三角形的某一边输出另外两条整数边,构成直角三角形;
转载于:https://www.cnblogs.com/jhz033/p/5791715.html