option=com_onlinejudge&Itemid=8&page=show_problem&category=109&problem=1064&mosmsg=Submission+received+with+ID+13620550">题目:uva :10123 - No Tipping 题目大意:给出l, m, n 分别表示 长度为l 的杠杆, 重量为 m, 有n个物体放在上方.问每次从上面挑选一个物品移除,能否使杠杆继续平衡.这个过程中都能…
Problem A - No Tipping As Archimedes famously observed, if you put an object on a lever arm, it will exert a twisting force around the lever's fulcrum. This twisting is called torque and is equal to the object's weight multiplied by its distance from…
这题的题意是 在双脚天平上有N块东西,依次从上面取走一些,最后使得这个天平保持平衡! 解题: 逆着来依次放入,如果可行那就可以,记得得有木板自身的重量. /************************************************************************* > File Name: 10123.cpp > Author: opas > Mail: 1017370773@qq.com > Created Time: 2016年10月22日…
UVA - 11853 思路:dfs,从最上面超过上边界的圆开始搜索,看能不能搜到最下面超过下边界的圆. 代码: #include<bits/stdc++.h> using namespace std; ; double l,r; int n; bool vis[N]={false}; bool flag=false; struct point { int x,y,r; }a[N]; bool intersect(point a,point b) { return (a.x-b.x)*(a.x…
UVA.548 Tree(二叉树 DFS) 题意分析 给出一棵树的中序遍历和后序遍历,从所有叶子节点中找到一个使得其到根节点的权值最小.若有多个,输出叶子节点本身权值小的那个节点. 先递归建树,然后DFS求解. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <string> #include <sstre…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=513 终于开始接触图了,恩,开始接触DFS了,这道题就是求连通分量,比较简单. #include<iostream> #include<cstring> using namespace std; int m, n; //记录连通块的数量 ][]; ][]; void…
题目链接:uva 12253 - Simple Encryption 题目大意:给定K1.求一个12位的K2,使得KK21=K2%1012 解题思路:按位枚举,不且借用用高速幂取模推断结果. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const ll ite=(1<<20)-1; ll N; /* l…
UVA - 1103Ancient Messages In order to understand early civilizations, archaeologists often study texts written in ancient languages.One such language, used in Egypt more than 3000 years ago, is based on characters called hieroglyphs.Figure C.1 shows…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=144 题意:给出一个n个结点的无向图以及某个结点k,按照字典序从小到大顺序输出从1到结点k的所有路径. 思路:如果直接矩阵深搜的话是会超时的,所以我们可以从终点出发,将与终点相连的连通块保存起来,这样dfs深搜时可以剪枝掉一些到达不了的点.只要解决了这个,dfs就是小问题. 这道题还有点坑的…
题目大意: 两题几何水题. 1.UVA 11646 - Athletics Track 如图,体育场的跑道一圈400米,其中弯道是两段半径相同的圆弧,已知矩形的长宽比例为a:b,求长和宽的具体数值. 2.UVA 11817 - Tunnelling the Earth 给出地球上起点和终点(均用度数的经纬度表示),从起点出发,可以沿着球面最短路径走.也可以钻隧道,走直线.求这两种方法的路程差. 题解: 1.UVA 11646 - Athletics Track http://uva.online…