Ural Vol1(dif>=900)
目前已AC: 2
1040.Airline Company(构造)
题目要求与每个顶点相连的所有边编号最大公约数为1,其实只要其中的两条边编号互质,所有边编号的最大公约数一定为1。我们知道相邻的数字一定互质,那么只要与一个顶点相连的所有边中有两条编号相邻,这个顶点就可以符合条件。DFS序列,对边进行编号刚好可以构造出满足要求的解,并且无解的情况是不存在的。
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-
# define MOD
# define INF
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<,l,mid
# define rch p<<|,mid+,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
, flag=;
char ch;
;
';
+(ch-');
return flag?-res:res;
}
void Out(int a) {
) {putchar('-'); a=-a;}
) Out(a/);
putchar(a%+');
}
;
//Code begin...
][], dfn[][], node[], n, tot;
vector<PII>edge;
void dfs(int x)
{
node[x]=;
FOR(i,,n) ) dfn[x][i]=dfn[i][x]=++tot, dfs(i);
}
int main ()
{
int m, u, v;
scanf("%d%d",&n,&m);
;
FOR(i,,n) ) dfs(i);
puts("YES");
; i<edge.size(); ++i) printf("%d ",dfn[edge[i].first][edge[i].second]);
putchar('\n');
;
}
1075.Thread in a Space(高中几何)
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-
# define MOD
# define INF
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<,l,mid
# define rch p<<|,mid+,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
, flag=;
char ch;
;
';
+(ch-');
return flag?-res:res;
}
void Out(int a) {
) {putchar('-'); a=-a;}
) Out(a/);
putchar(a%+');
}
;
//Code begin...
template<class T>
T sqr(T x)
{
return x*x;
}
int main()
{
double xa, ya, za, xb, yb, zb, xc, yc, zc, r;
scanf("%lf%lf%lf", &xa, &ya, &za);
scanf("%lf%lf%lf", &xb, &yb, &zb);
scanf("%lf%lf%lf", &xc, &yc, &zc);
scanf("%lf", &r);
double ab=sqrt(sqr(xa-xb) + sqr(ya-yb) + sqr(za-zb));
double ac=sqrt(sqr(xa-xc) + sqr(ya-yc) + sqr(za-zc));
double bc=sqrt(sqr(xb-xc) + sqr(yb-yc) + sqr(zb-zc));
*ac*bc));
double a=acos(r/ac);
double b=acos(r/bc);
if(a+b>=c) printf("%.2lf\n", ab);
else printf("%.2lf\n", (c-a-b)*r + sqrt(sqr(ac) - sqr(r)) + sqrt(sqr(bc) - sqr(r)));
;
}
Ural Vol1(dif>=900)的更多相关文章
- ural 1269. Obscene Words Filter
1269. Obscene Words Filter Time limit: 0.5 secondMemory limit: 8 MB There is a problem to check mess ...
- URAL 1145—— Rope in the Labyrinth——————【求树的直径】
Rope in the Labyrinth Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64 ...
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- ural 1208 Legendary Teams Contest
题意描述:给定K支队伍,每队三个队员,不同队伍之间队员可能部分重复,输出这些队员同时能够组成多少完整的队伍: DFS,利用DFS深度优先搜索,如果该队所有队员都没有被访问过,那么将该队计入结果,再去选 ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
随机推荐
- js 弹层 提示
<!DOCTYPE html><html style="height: 100%;"><head lang="en"> &l ...
- xcconfig 文件配置文件 问题
与公司 QA 聊天,已不止一次被吐槽说移动端从开发环境转到生产环境时,还要靠修改代码来配置对应的环境参数.她认为,从 App 转测试之后,就不应该再修改代码,可以把所有的环境配置都整合到配置文件中,这 ...
- [原]界面上有几个球队名字的列表,将鼠标放到球队名字上就变为红色背景,其他球队背景颜色为白色,点击一个球队的时候就将点击的球队变为fontSize=30字体(fontSize=‘’回到默认)。
window.onload = function () { var uls = document.getElementById('ui').getElementsByTagNa ...
- PD生成oracle表名带引号解决方案
使用PowerDesigner生成数据库建表SQL脚本时,尤其是Oracle数据库时,表名一般会带引号.其实加引号是PL/SQL的规范,数据库会 严格按照“”中的名称建表,如果没有“”,会按照ORAC ...
- 服务器 vps 空间
服务器 服务器是一台独立的机器,拥有独立的ip,磁盘空间,内存空间,可以认为是一台功能强大的电脑. VPS VPS是利用虚拟化技术将服务器虚拟成多台服务器,独立的ip,磁盘空间,内存空间,服务器的vp ...
- 【转】获取/设置IFRAME内对象元素的几种JS方法
1.IE专用(通过frames索引形象定位): document.frames[i].document.getElementById('元素的ID'); 2.IE专用(通过IFRAME名称形象定位): ...
- Diamond Collector
Diamond Collector 题目描述 Bessie the cow, always a fan of shiny objects, has taken up a hobby of mining ...
- 使用jquery模拟键盘事件,但window系统并不会真的响应事件,只是浏览器当前页面会响应而已
<!DOCTYPE html> <html> <head> <title>Demo</title> <meta http-equiv= ...
- 总结NAND FLASH控制器的操作
初始化 NAND FLASH: 1)寄存器 NFCONT,用于开启 NAND FLASH控制器: 2)向寄存器NFCMD写入命令: 3)向寄存器NFADDR写入地址: 4)使用寄存器NFDATA进行数 ...
- HRBUST 1909 理工门外的树(双数组实现线段树功能)
线段树固然可以做,但是在考虑线段树之前应该先考虑一下,这种用两个数组来解决问题的方法能不能行,如果行的话,就会为我们省很多时间,毕竟线段树代码量比较大 #include<iostream> ...