Codeforces Beta Round #69 (Div. 2 Only)——A,B,D
来源:互联网 发布:遍历所有子节点 js 编辑:程序博客网 时间:2024/05/22 16:55
A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6,4 are not.
The next prime number after x is the smallest prime number greater than x. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note that there is exactly one next prime number after each number. So 5 is not the next prime number for 2.
One cold April morning Panoramix predicted that soon Kakofonix will break free from his straitjacket, and this will be a black day for the residents of the Gallic countryside.
Panoramix's prophecy tells that if some day Asterix and Obelix beat exactly x Roman soldiers, where x is a prime number, and next day they beat exactly y Roman soldiers, where y is the next prime number after x, then it's time to wait for Armageddon, for nothing can shut Kakofonix up while he sings his infernal song.
Yesterday the Gauls beat n Roman soldiers and it turned out that the number n was prime! Today their victims were a troop of mRomans (m > n). Determine whether the Gauls should wait for the black day after today's victory of Asterix and Obelix?
The first and only input line contains two positive integers — n and m (2 ≤ n < m ≤ 50). It is guaranteed that n is prime.
Pretests contain all the cases with restrictions 2 ≤ n < m ≤ 4.
Print YES, if m is the next prime number after n, or NO otherwise.
#include <iostream>#include <cstdio>using namespace std;bool judge(int x){ bool flag=true; for(int i=2;i*i<=x;i++) if(x%i==0) flag=false; return flag;}int main(){ int a,b,i; cin>>a>>b; for(i=a+1;;i++) if(judge(i)) break; if(i==b) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0;}
Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!
There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle...
Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a human, but is the mantel clock, which was often used as an alarm clock.
Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they could not determine when it was time to drink morning tea, and when it was time for an evening stroll.
Fortunately, deep in the basement are lying digital clock showing the time in the format HH:MM. Now the residents of the castle face a difficult task. They should turn Cogsworth's hour and minute mustache hands in such a way, that Cogsworth began to show the correct time. Moreover they need to find turn angles in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.
You can only rotate the hands forward, that is, as is shown in the picture:
As since there are many ways too select such angles because of full rotations, choose the smallest angles in the right (non-negative) direction.
Note that Cogsworth's hour and minute mustache hands move evenly and continuously. Hands are moving independently, so when turning one hand the other hand remains standing still.
The only line of input contains current time according to the digital clock, formatted as HH:MM (00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59). The mantel clock initially shows 12:00.
Pretests contain times of the beginning of some morning TV programs of the Channel One Russia.
Print two numbers x and y — the angles of turning the hour and minute hands, respectively (0 ≤ x, y < 360). The absolute or relative error in the answer should not exceed 10 - 9.
#include <iostream>#include <cstdio>using namespace std;int main(){ int a,b; scanf("%d:%d",&a,&b); int y=b*6; if(a>=12) a-=12; double x=(a*60+b*1.0)/2; if(x==(int)x) printf("%.0lf %d",x,y); else printf("%.1lf %d",x,y); cout<<endl; return 0;}
For some reason in many American cartoons anvils fall from time to time onto heroes' heads. Of course, safes, wardrobes, cruisers, planes fall sometimes too... But anvils do so most of all.
Anvils come in different sizes and shapes. Quite often they get the hero stuck deep in the ground. But have you ever thought who throws anvils from the sky? From what height? We are sure that such questions have never troubled you!
It turns out that throwing an anvil properly is not an easy task at all. Let's describe one of the most popular anvil throwing models.
Let the height p of the potential victim vary in the range [0;a] and the direction of the wind q vary in the range [ - b;b]. p and q could be any real (floating) numbers. Then we can assume that the anvil will fit the toon's head perfectly only if the following equation has at least one real root:
Determine the probability with which an aim can be successfully hit by an anvil.
You can assume that the p and q coefficients are chosen equiprobably and independently in their ranges.
The first line contains integer t (1 ≤ t ≤ 10000) — amount of testcases.
Each of the following t lines contain two space-separated integers a and b (0 ≤ a, b ≤ 106).
Pretests contain all the tests with 0 < a < 10, 0 ≤ b < 10.
Print t lines — the probability of a successful anvil hit for each testcase. The absolute or relative error of the answer should not exceed10 - 6.
#include <iostream>#include <cstdio>using namespace std;int main(){ int t; cin>>t; while(t--) { double a,b; cin>>a>>b; if(b==0) { printf("1\n"); continue; } double ans=0.5; //画图求解即可,b为x轴,注意a/4与b的关系即可 if(a>b*4) ans+=0.5-b/a; else ans+=a/16/b; printf("%.10lf\n",ans); } return 0;}
- Codeforces Beta Round #69 (Div. 2 Only)——A,B,D
- Codeforces Beta Round #75 (Div. 2 Only)——D
- Codeforces Beta Round #93 (Div. 2 Only)——B
- Codeforces Beta Round #91 (Div. 2 Only)——B
- Codeforces Beta Round #18 (Div. 2 Only)——B
- Codeforces Beta Round #72 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #73 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #76 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #77 (Div. 2 Only)——A,B,C
- Codeforces Beta Round #18 (Div. 2 Only)——A
- Codeforces Beta Round #69 (Div. 2 Only) A题
- Codeforces Beta Round #4 (Div. 2 Only)——D. Mysterious Present
- 【KMP】Codeforces Beta Round #93 (Div. 2 Only) D
- Codeforces Beta Round #4 (Div. 2 Only)D. Mysterious Present
- Codeforces Beta Round #18 (Div. 2 Only) D - Seller Bob
- Codeforces Beta Round #4 (Div. 2 Only) D. Mysterious Present
- Codeforces Beta Round #91 (Div. 2 Only) D. Lucky Transformation
- Codeforces Beta Round #22 (Div. 2 Only)-D. Segments
- DOC:华为GPON原理介绍
- 第五次作业
- 哈佛寓言十三则
- Java和C++判断字符串是否相等
- Android实现图片滚动控件,含页签功能,让你的应用像淘宝一样炫起来
- Codeforces Beta Round #69 (Div. 2 Only)——A,B,D
- 在 Android 中使用各种控件(View)
- 得到 ExecutorService 当前活动的线程数
- UNICODE编码之小端
- 第8章 标准IO库
- Java中的final,finalized,finally用法
- 二十岁出头,你一无所有,但你却拥有一切
- WebService之java调用天气预报案例
- linux以及vim配置问题积累