Bullseye
来源:互联网 发布:天网防火墙软件 编辑:程序博客网 时间:2024/06/14 05:38
Problem
Maria has been hired by the Ghastly Chemicals Junkies (GCJ) company to help them manufacture bullseyes. A bullseye consists of a number of concentric rings (rings that are centered at the same point), and it usually represents an archery target. GCJ is interested in manufacturing black-and-white bullseyes.
Maria starts with t millilitres of black paint, which she will use to draw rings of thickness 1cm (one centimetre). A ring of thickness 1cm is the space between two concentric circles whose radii differ by 1cm.
Maria draws the first black ring around a white circle of radius r cm. Then she repeats the following process for as long as she has enough paint to do so:
- Maria imagines a white ring of thickness 1cm around the last black ring.
- Then she draws a new black ring of thickness 1cm around that white ring.
The area of a disk with radius 1cm is π cm2. One millilitre of paint is required to cover area π cm2. What is the maximum number of black rings that Maria can draw? Please note that:
- Maria only draws complete rings. If the remaining paint is not enough to draw a complete black ring, she stops painting immediately.
- There will always be enough paint to draw at least one black ring.
Input
The first line of the input gives the number of test cases, T. T test cases follow. Each test case consists of a line containing two space separated integers: r and t.
Output
For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the maximum number of black rings that Maria can draw.
Limits
Small dataset
1 ≤ T ≤ 1000.
1 ≤ r, t ≤ 1000.
Large dataset
1 ≤ T ≤ 6000.
1 ≤ r ≤ 1018.
1 ≤ t ≤ 2 × 1018.
Sample
Input
5
1 9
1 10
3 40
1 1000000000000000000
10000000000000000 1000000000000000000
Output
Case #1: 1
Case #2: 2
Case #3: 3
Case #4: 707106780
Case #5: 49
#include<stdio.h>#include<string.h>#include<stdlib.h>int main(){ long long ans,T,i,j,ncas=1,r,t,start,res; FILE *file; freopen("C:\\Users\\think\\Desktop\\in.in","r",stdin); file=freopen("C:\\Users\\think\\Desktop\\output.txt","w",stdout); scanf("%lld",&T); while(T--) { scanf("%lld%lld",&r,&t); start=ans=res=0; start=2*r+1; for(i=1;;i++) { ans=2*i*r+2*(i+1)*i+i+start; if(ans>t)break; } //printf("%lld\n",i); fprintf(file,"Case #%lld: %lld\n",ncas++,i); } return 0;}
- Bullseye
- WOJ1114-Bullseye
- pku 2272 Bullseye
- POJ-2272-Bullseye
- POJ 2272 Bullseye G++
- Google Code Jam 2013 - Bullseye
- Bullseye Coverage license破解笔记
- C++ 代码覆盖率工具Bullseye Coverage
- 移植 bullseye coverage—arm 版本
- Bullseye Code Coverage 代码分析工具地址
- C++ 代码覆盖率工具Bullseye Coverage(收藏)
- Bullseye on Google: Hackers expose holes in GMail, Blogspot, Search Appliance
- 安卓之旅第四站--实战演练之Bullseye小游戏制作
- libSVM介绍
- [cocos2d-x BUG1]CCLabelBMFont,字符作为child引用会存在错位
- mips syscall返回值与errno设置
- FAILED: ParseException line mismatched input '<EOF>' expecting StringLiteral near 'by' in
- Android之旅--Handler与多线程
- Bullseye
- 递归生成菜单树的下拉框 struts2
- Centos搭建Samba
- Android系统在超级终端下必会的命令大全(adb shell命令大全)
- 让一个div显示在最前面
- ruby如何使用require加载从外部定义的类或模块
- Linux命令之xargs命令详解
- ASP.NET网页语法概述&asp.net网页
- Java Example5 小程序